Click here to Skip to main content
11,720,545 members (69,944 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Office 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;
                        anchorlist.Add(attr);
                        linklist.Add(href);
                        hrefcheck = hrefcheck.NextMatch();
                    }
 
                    string matchurl = "xyz.com";
 
                    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
EricThe669
Edited 30-Jul-12 7:44am
(no name)115.6K
v2
Comments
Kenneth Haugland at 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 at 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 at 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 at 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 at 30-Jul-12 15:33pm
   
didnt work
jk0391 at 27-May-15 15:51pm
   
You should be using the WorkSheet variable, not the Excel object.

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

Right??

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 2,129
1 OriginalGriff 884
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540


Advertise | Privacy | Mobile
Web04 | 2.8.150901.1 | Last Updated 27 May 2015
Copyright © CodeProject, 1999-2015
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