Scripting Issue: Dynamic Table Exporting Numbers as Strings in Excel file type #2191
-
Hello BIRTians, I’m seeking some guidance on a challenge I’m facing with BIRT. I’m working on a report that requires a dynamic table, where the number of columns changes based on user configurations. The table can have a minimum of one column and potentially many more. While I’m aware that this can be achieved using a BIRT CrossTab, I’m unable to use that approach due to certain constraints (which I prefer not to discuss here). To work around this, I’ve implemented a solution using JavaScript in the beforeFactory event, and I’ve managed to get most of it working. However, I’ve encountered an issue when exporting the report to Excel (.xlsx format): Numeric values are being treated as strings, and Excel prompts users to convert them manually (please refer to the attached screenshot). I understand this is happening because I’m using labels to display the data, which causes Excel to interpret all values as text. My question is: Is there a way to ensure that numeric values are recognized as numbers in Excel via BIRT scripting ? Any suggestions or workarounds would be greatly appreciated. I’ve attached the .rptdesign file, the exported Excel file, and relevant screenshots for reference. Please let me know if any additional information is needed. Tagging @speckyspooky and @hvbtup for their insights, your input would be incredibly helpful! Thanks in advance for your support! Numbers treated as string issue snapshot Rptdesign, excel files |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hello @raviprsd18, For exampe the dynamic text can switch based on the content type between numeric- (content type: plain) and string-value (content type: html) for excel. Here is my solution how you can handle your problem:
Here is the result screen based on your report with my change: Report with the change: DynamicTablePOC_Changed_TG.zip |
Beta Was this translation helpful? Give feedback.
-
@speckyspooky thanks for the help. I tried using dataset and datascript via scripting but I faced lot of issues and it didn't succeeded. If possible can you share me the sample code. |
Beta Was this translation helpful? Give feedback.
Hello @raviprsd18,
I looked into your report and the special topic is here your element "Label" because thus type is by default a string type and cannot be converted to a numeric value on xlsx side. The excel-emitter must know if it is a string-value or a numeric-value.
For exampe the dynamic text can switch based on the content type between numeric- (content type: plain) and string-value (content type: html) for excel.
Here is my solution how you can handle your problem: