Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Apr 12, 2013 8:38 am

Hi!
I evaluate currently Spire.XLS and until now it seems to be a very impressive product.

But now I need some help:

I have an Excel-sheet with a named table (datatable). In this table is a named range datatableHeader with named cells (datatableHeaderNoCol, datatableHeaderTimestampCol, datatableHeaderValueCol and datatableHeaderRefValueCol).
I When i try to access the cells inside the table header, an exception occurs:

Code: Select all
datatable[[#Headers] is not valid named range


The code:
Code: Select all
int idxTimestampColumn = worksheet.Names["datatableHeaderTimestampCol"].RefersToRange.Column;


Where is my fault? :roll:
Attachments
names_manager.PNG
names_manager.PNG (12.39 KiB) Viewed 4583 times

andreas.weirauch
 
Posts: 3
Joined: Mon Apr 08, 2013 11:41 am

Fri Apr 12, 2013 9:34 am

Dear Andreas,

Thanks for your inquiry.
Please try the code snippet below.
Code: Select all
INamedRange rg = workbook.NameRanges.GetByName("datatableHeaderTimestampCol");
IXLSRange range = rg.RefersToRange;
int idxTimestampColumn = range.Column;

If you still have this issue, please provide us your template file. Thanks!

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Apr 12, 2013 12:30 pm

Thanks for the quick response!

It does not work anyway

My entire test code is:
Code: Select all
Workbook workbook = new Workbook();
FileStream fs = new FileStream(@"D:\temp\Sample.xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
workbook.LoadFromStream(fs, ExcelVersion.Version2010);
Worksheet worksheet = workbook.Worksheets[0];

INamedRange rg = workbook.NameRanges.GetByName("datatableHeaderTimestampCol");
IXLSRange range = rg.RefersToRange;
int idxTimestampColumn = range.Column;
Attachments
Sample.zip
(10.43 KiB) Downloaded 373 times

andreas.weirauch
 
Posts: 3
Joined: Mon Apr 08, 2013 11:41 am

Mon Apr 15, 2013 3:39 am

Dear Andreas,

Thanks for your feedback.
Sorry for the delay response for the weekends here.
Our Spire.Xls component doesn't support structured references with Excel tables at present. Sorry for the inconvenience.
But our dev team is working on this feature. We can support this feature next version.
Once new version has been released, we will inform you immediately.

Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Mon Apr 15, 2013 6:19 am

Hi!

Thanks for the info.
Until then I will then use a workaround.

Regards
Andreas

andreas.weirauch
 
Posts: 3
Joined: Mon Apr 08, 2013 11:41 am

Return to Spire.XLS