How to upload and use an Excel File



  • Hello,

    I am having a very hard time understanding your documentation overall. One thing I am particularly curious about is something you mention in your Xlsx recipe blog here: [https://jsreport.net/learn/xlsx](link url)

    You say there, "Another approach we recommend is to create the whole excel the first, upload it into jsreport and then only replace its data, which is simple."

    However, there is no explanation of how to do this, or work with the uploaded file. I found in the Studio UI under 'xlsxTemplates' you can upload an Excel file from my local hard drive, but after that, I have no idea what to do. How do I access the file? What do I do to replace the data?


  • administrators

    hi!

    You say there, "Another approach we recommend is to create the whole excel the first, upload it into jsreport and then only replace its data, which is simple."
    However, there is no explanation of how to do this, or work with the uploaded file. I found in the Studio UI under 'xlsxTemplates' you can upload an Excel file from my local hard drive, but after that, I have no idea what to do. How do I access the file? What do I do to replace the data?

    xlsx recipe works by modifying internal representation of xlsx (xml files using Office Open XML specification), we let your code to modify the files that are present inside the xlsx (the xlsx is a zip file that contains multiple xml files), you can use one of that helpers xlsxReplace, xlsxMerge, xlsxAdd that we provide to modify/add the contents to one of the internal files of the xlsx. the modifications that you should do are mostly about using the data that your template receives to create dynamic content that should be in the xml tags that are part of your final xlsx. each time that you use a xlsx helper you are modifying part of your final xlsx file.

    i guess there is no deep guide of how to do this because we have not had the time yet to do it but we will as soon we finish some other stuff first.

    I have no idea what to do.

    if you are going to upload an xlsx file that contains some pre-defined layout, then in order to know how to modify by code in jsreport template you should know first how it looks, on your computer you can rename your .xlsx file to .zip then unzip it and inspect all the internal files there, there are a lot there but you should try to focus mostly in for example xl/worksheets/sheet1.xml that contains the content of the cells, then you can use one of the helpers that we provide to add/modify/replace xml tags inside it.

    What do I do to replace the data?

    just use the helpers that we provide, specify the target paths to modify and put xml tags that should be the new content or should be added, depending on the specific helper that you use.

    i know all of this sounds hard, but this is the most powerful way that we found to create dynamic xlsx with rich content. we hope that we can make this more easy in the future, let's see. for the time being i have added a note to out internal tasks to add some guide on how to work with existing xlsx files that contain layout


Log in to reply
 

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