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.

Mon Dec 17, 2018 12:04 pm

We get an exception when we use the excel-function "WEEKNUM()" with the optional second parameter (when should the week start) in a formula like "text "&KALENDERWOCHE(fieldreference; 2):

Code: Select all
Unexpected token.Unexpected token type: tInteger, string value:   at position 37. Formula: "KW "&WEEKNUM('Raw Data - Mails'!C19,2), Position: 37 =>    bei spr4164.0(String A_0, Exception A_1)
   bei spr4164.0(String A_0)
   bei spr4144.0(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
   bei spr4144.0(ParseFormulaOptions A_0, Dictionary`2 A_1, ParseParameters A_2, ExcelFunction A_3)
   bei spr4144.0(ExcelFunction A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
   bei spr4144.0(Dictionary`2 A_0, Int32 A_1, ParseFormulaOptions A_2, ParseParameters A_3)
   bei spr4144.0(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions& A_3, ParseParameters A_4)
   bei spr4144.0(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
   bei spr4144.0(Priority A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
   bei spr4144.1(String A_0, Dictionary`2 A_1, Int32 A_2, ParseFormulaOptions A_3, ParseParameters A_4)
   bei Spire.Xls.Core.Spreadsheet.FormulaUtil.1(String A_0, IWorksheet A_1, Dictionary`2 A_2, Int32 A_3, Dictionary`2 A_4, ParseFormulaOptions A_5, Int32 A_6, Int32 A_7)
   bei Spire.Xls.Core.Spreadsheet.FormulaUtil.0(String A_0, IWorksheet A_1, Dictionary`2 A_2)
   bei spr4319.0(XmlReader A_0, IInternalWorksheet A_1, Int32 A_2, Int32 A_3, Int32 A_4)
   bei spr4319.0(XmlReader A_0, IInternalWorksheet A_1, List`1 A_2, Int32 A_3, Int32 A_4)
   bei spr4319.0(XmlReader A_0, IInternalWorksheet A_1, List`1 A_2, String A_3, Int32 A_4)
   bei spr4319.0(XmlReader A_0, IInternalWorksheet A_1, List`1 A_2, String A_3)
   bei spr4319.0(XmlReader A_0, XlsWorksheet A_1, String A_2, MemoryStream& A_3, MemoryStream& A_4, List`1 A_5, Dictionary`2 A_6, Dictionary`2 A_7)
   bei spr523.1(XlsWorksheet A_0, Dictionary`2 A_1)
   bei Spire.Xls.Core.Spreadsheet.XlsWorksheet.ParseData(Dictionary`2 dictUpdatedSSTIndexes)
   bei spr4319.0(Dictionary`2 A_0)
   bei spr256.0(List`1& A_0)
   bei spr256.1(List`1& A_0)
   bei Spire.Xls.Core.Spreadsheet.XlsWorkbook.0(Stream A_0, String A_1)
   bei Spire.Xls.Core.Spreadsheet.XlsWorkbook.0(Stream A_0, String A_1, ExcelVersion A_2, ExcelParseOptions A_3)
   bei Spire.Xls.Core.Spreadsheet.XlsWorkbook.0(String A_0, String A_1, ExcelVersion A_2, ExcelParseOptions A_3)
   bei Spire.Xls.Core.Spreadsheet.XlsWorkbook..ctor(spr2501 A_0, Object A_1, String A_2, ExcelParseOptions A_3, Boolean A_4, String A_5, ExcelVersion A_6)
   bei spr861.0(Object A_0, String A_1, ExcelParseOptions A_2, Boolean A_3, String A_4, ExcelVersion A_5)
   bei spr3457.0(String A_0, ExcelParseOptions A_1, Boolean A_2, String A_3, ExcelVersion A_4)
   bei Spire.Xls.Workbook.LoadFromFile(String fileName, ExcelVersion version)
   bei Spire.Xls.Workbook.LoadFromFile(String fileName)
   bei (<our function call stack>)

--------
For explanation: we use the german version of excel, so the function is called KALENDERWOCHE('Raw Data - Mails'!C19;2)
Attachments
tescht.zip
conversion WEEKNUM with 2. parameter crashes (see first page, red marked column)
(13.79 KiB) Downloaded 193 times

heldflo
 
Posts: 3
Joined: Mon Dec 17, 2018 10:47 am

Tue Dec 18, 2018 3:09 am

Hi,

Thanks for your inquiry.
Your issue is caused by the culture. Please refer to following code to set the culture.
Code: Select all
            CultureInfo cc = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Workbook book = new Workbook();
            book.LoadFromFile(@"F:\tescht.xlsm");
            //your code...
            Thread.CurrentThread.CurrentCulture = cc;

If you still have the issue, please share your full code for further investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Dec 18, 2018 8:35 am

Thank's a lot - this solution solved it.

heldflo
 
Posts: 3
Joined: Mon Dec 17, 2018 10:47 am

Tue Dec 18, 2018 8:37 am

Hi,

Thanks for your feedback.
Any question, just feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS