0 Replies - 13356 Views - Last Post: 20 June 2011 - 08:39 AM Rate Topic: -----

#1 daya88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-June 11

C# import Excel - XlWBATemplate.xlWBATWorksheet error

Posted 20 June 2011 - 08:39 AM

Hello,

I am trying to create a new Excel file with a blank sheet.
My code is the following :

using Excel = Microsoft.Office.Interop.Excel;

public void format()
        {
            List<string> sheets = getSheetName(path);

            Excel._Application xlsAppNew = new Excel.Application();
            xlsAppNew.Visible = true;
            
            foreach (string s in sheets)
            {

                if (s.Contains("A,B") == true)
                {
                    char[] delim = { 'A' };

                    string[] grupa = s.Split(delim, 4);

                    listView1.Items.Add(grupa[0] + "A");
                    Excel.Workbook workbook = Excel.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
                    Excel.Sheets newSheet = workbook.Worksheets;
                    
                    
                    listView1.Items.Add(grupa[0] + "B");
                    //save in another sheet

                }
                else
                    listView1.Items.Add(s.ToString());
                //save in another sheet
            }
        }



But I get the following error : The name 'XlWBATemplate' does not exist in the current context.
What`s missing?

Please help.

This post has been edited by NickDMax: 20 June 2011 - 09:33 AM
Reason for edit:: Fixed code tags: [code]... paste code here [/code]


Is This A Good Question/Topic? 0
  • +

Page 1 of 1