Excel dynamic table corrupts the file



  • Hi I'm trying to make a dynamic table in jsreport XLSX recipe using handlebars. https://playground.jsreport.net/w/bamdad-b/JBtX70vq
    As you can see the file is corrupted when I try to add the third column to the table. The result is the same in the studio and my .NET application.
    The web version of Excel is capable of repairing the file but when using Microsoft Office Excel on windows, it keeps asking to repair the file each time I open it and claims that there was a problem in "\xl\tables\table1.xml" but it doesn't change anything in that file and prompts me to repair the file again when I open it.



  • Unfortunately, tables in open xml are complex. There is some documentation to it here
    https://docs.microsoft.com/en-us/office/open-xml/working-with-tables

    However, the best approach is probably to create a table with two columns in excel and a table with three columns in another file. Unzip both and compare what's different. Then replicate it with xlsx helper functions. I know this is very time consuming, but at this moment probably the only approach.



  • @jan_blaha thanks for your reply. My question is: Isn't an Excel file just a collection of some XMLs? Well I change my table1.xml to something Excel would create itself. Then where's the problem coming from? Which other file should I look into to make it work? (I compared every file in the corrupted and refined excel files but found nothing. The only difference seemed to be in the Table1.xml and SharedString.xml but fixing them didn't work.)
    If you please give me a clue where my problem lies at, I think I would be able to work it out. Thank you for your great library and support.



  • This could be the minimal example for adding a column to a table
    https://playground.jsreport.net/w/anon/5BQ1OXu7

    It took me also two hours to come up with that, but I just used the approach I mentioned earlier without any extra knowledge of openxml or jsreport involved. Just a diff tool and tedious hours of work...

    create a table with two columns in excel and a table with three columns in another file. Unzip both and compare what's different. Then replicate it with xlsx helper functions



  • So I guess 2 hours wasn't enough for me to find such a simple and irrelevant-looking problem. Thank you for your time. Great library btw, Thank you very much.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.