Table name evaluation

May 2, 2014 at 10:32 PM
Hi,

I tried to retreive an excel table using this code :
    XSSFWorkbook workbook = new XSSFWorkbook(fs);
    var table = workbook.GetName("Table1");
The returned value is null.

Does someone have a solution or a workaround to solve this ?

Thanks for advance.

Sybaris
May 16, 2014 at 3:16 PM
Hi,

I found the solution myself :
Here the code I used :
            FileStream fs = new FileStream("c:\MyExcelFile.xls"", FileMode.Open);
            XSSFWorkbook workbook = new XSSFWorkbook(fs);
            ISheet iWorksheet = workbook.GetSheet("MyWorkSheetName");
            XSSFSheet worksheet = (XSSFSheet)iWorksheet;
            List<XSSFTable> tables = worksheet.GetTables();
            XSSFTable table = tables.Single<XSSFTable>(x => string.Compare(x.Name, "MyTableName", true) == 0);
I hope this will be usefull for someone...

Sybaris
Marked as answer by tonyqus on 5/17/2014 at 4:40 PM
Coordinator
May 18, 2014 at 12:39 AM
GetName is for named range instead of Excel table. This is by design