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.

Wed Oct 23, 2013 6:57 am

Hello,

we are looking for an engine to open, edit or save .xlsx files.
So i downloaded the trial version 7.1 of Spire.XLS for .NET. Now i tried to open an .xlsx file. But i always got this error:
Code: Select all
Unexpected token.Unexpected token type: tNumber, string value: ,1  at position 10. Formula: DATE($B$4,1,1), Position: 12

If i manually convert this .xlsx file to a .xls file then i can open it without any problems.
So now i can read the xls file and color some cells. But i have problems with adding a dropdown list or to lock a cell. I tried both with your provided sample code.

Please can you help me with this problems?
Thank you.
Tim

tim.schneider
 
Posts: 5
Joined: Tue Oct 22, 2013 12:44 pm

Wed Oct 23, 2013 9:10 am

Dear Tim,

Thanks for your interested in our Spire.Xls.
Would you please provide us with your original excel file? It will help us do a research and solve the error soon. Thank you!

Please kindly refer to the following code to add a dropdown list and lock a cell.
Code: Select all
            Workbook workbook = new Workbook();
            Worksheet sheet= workbook.Worksheets[0];
            sheet.Range["A1"].Text="A";
            sheet.Range["A2"].Text="B";
            sheet.Range["A3"].Text="C";
            sheet.Range["A4"].Text="ABC";
           
            // Add a dropdown list and the data range is from A1 to A3
            sheet.Range["D1"].DataValidation.DataRange=sheet.Range["A1:A3"];
           
            //Lock A4 cell
            sheet.Protect("test");
            sheet.Range["A4"].Style.Locked = true;

            workbook.SaveToFile("result.xlsx",ExcelVersion.Version2007);


Welcome to write to us again in case you have further issues.

Best regards,
Amy
E-iceblue support team
User avatar

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

Wed Oct 23, 2013 10:12 am

Hello Amy,

thanks for your fast response.
I attached a sample .xlsx file.

thanks
Attachments
DatatableSample.zip
(6.79 KiB) Downloaded 314 times

tim.schneider
 
Posts: 5
Joined: Tue Oct 22, 2013 12:44 pm

Thu Oct 24, 2013 3:47 am

Dear Tim,

Thanks for your providing.
I used version 7.1 and version 7.1.20 which was released yesterday to test your sample file in our side, but I didn't reproduce the error you met. We think the error maybe caused by the decimal separator of your local culture.
Please try the following code.
Code: Select all
 CultureInfo cc = Thread.CurrentThread.CurrentCulture;
 Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

 Workbook workbook = new Workbook();
 workbook.LoadFromFile(@"..\..\DatatableSample.xlsx");
 string filepath = "result.xlsx";
 workbook.SaveToFile(filepath, ExcelVersion.Version2007);

 Thread.CurrentThread.CurrentCulture = cc;

 System.Diagnostics.Process.Start(filepath);


If you still have the issue, please tell us.

Best regards,
Amy
E-iceblue support team
User avatar

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

Thu Oct 24, 2013 5:45 am

Hello Amy,

this solution works well for my problem.
Thank you very much!

Have a nice day.
Best regards
Tim

tim.schneider
 
Posts: 5
Joined: Tue Oct 22, 2013 12:44 pm

Thu Oct 24, 2013 6:41 am

Hello Amy,

i have another question. Can i open .xlsm files?
Because if i try this i get this error: "Value cannot be NULL. Parameter name: root"

Do you need the .xlsm file?

Thank you.
Best regards
Tim

tim.schneider
 
Posts: 5
Joined: Tue Oct 22, 2013 12:44 pm

Thu Oct 24, 2013 7:26 am

Hello Tim,

Yes, it would be very helpful to reproduce the issue you encountered.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Oct 24, 2013 8:17 am

Hello Gary,

i attached a sample file. It also contains a few macros.

Thanks.
Tim

[edit: i have deleted the attachment. If you need it again i can send it to you via email.]
Last edited by tim.schneider on Mon Oct 28, 2013 8:40 am, edited 1 time in total.

tim.schneider
 
Posts: 5
Joined: Tue Oct 22, 2013 12:44 pm

Thu Oct 24, 2013 9:32 am

Hello Tim,

We have reproduced the issue, which has been transferred to our Dev team, once there are any progress from them, we will infrom you.
Sorry for inconvenience.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Nov 14, 2013 5:59 am

Hello Tim,

The issue has been resolved, and the newest hotfix has been released, please download and test Spire.XLS7.1.24 from the following link.
http://www.e-iceblue.com/Download/downl ... t-now.html
Kindly note that please add the version when loading like as below.
Code: Select all
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"..\..\Auftragsliste_leer.xlsm", ExcelVersion.Version2007);


If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Nov 20, 2013 9:36 am

Hello Tim,

Have you tested the newest hotfix? Has your issue been resolved? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS