Click here to Skip to main content
12,884,793 members (32,468 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Office MS-Excel
Hi I have following code that works fine, I can get values and add them to excel sheet. Only problem i have is last line
xla.Cells[add, 4] = anchorlist;

it wont print the value for this anchor text "Missing parameter does not have a default value. Parameter name: parameters"
any idea how to fix it? Thanks

Match hrefcheck = hrefRegex.Match(htmlpage);
                    ArrayList linklist = new ArrayList();
                    // linklist.Add("<BASE href=\"" + url + "\">" + url);
                    ArrayList anchorlist = new ArrayList();
                    while (hrefcheck.Success)
                        string href = hrefcheck.Groups["href"].Value; //link url
                        string attr = hrefcheck.Groups["Anchor"].Value;
                        hrefcheck = hrefcheck.NextMatch();
                    string matchurl = "";
                    foreach (string str in linklist)
                        if (str.Contains(matchurl) == true)
                            Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
                            Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet);
                            Worksheet ws = (Worksheet)xla.ActiveSheet;
                            xla.Visible = true
                            xla.Cells[add, 1] = urltextBox.Text;
                            xla.Cells[add, 2] = str;
                            xla.Cells[add, 3] = s;
                            xla.Cells[add, 4] = anchorlist;
Posted 30-Jul-12 7:43am
Updated 30-Jul-12 7:44am
Kenneth Haugland 30-Jul-12 13:47pm
Are you sure the add has a value? And have you tried xla.Cells[add, 1].Value = str; etc ?
Kenneth Haugland 30-Jul-12 13:52pm
And also, o you really mean to create a new file fo reach of the parameters in linklist that has a matchurl?
TAR_FAST 30-Jul-12 14:09pm
Yes, the create file etc everything works fine, the values are added only value it is not picking up is the anchortag
Kenneth Haugland 30-Jul-12 14:14pm
It also looks like you are trying to write an array to a single cell in anchorlist, you should write anchorlist.tostring in that one and see what haoppens.
TAR_FAST 30-Jul-12 15:33pm
didnt work
jk0391 27-May-15 15:51pm
You should be using the WorkSheet variable, not the Excel object.

ws.Cells(row, column) = "value";


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 27 May 2015
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100