Has anyone done Excel file generation in Salesforce with bit complex formatting? If so appreciate any guidance or reference.

I already tried formatting with CSS and having the contentType="application/vnd.ms-excel" which doesn't give me the correct formatting always.

image e.g. In the attached image, the table rows/column colspan are dynamic. Background colors work fine with CSS but not colspan or width.

I wanted to try XML option as described here but the generated XML file is always having the text SfdcApp.Visualforce.viewstate.ViewstateSender.sendViewstate('https://cs58.salesforce.com', 'StackingPlanExcelMadhura'); at the end and due to that Excel can't open the file.

Correction for these two options or any other option would be appreciated.

  • Found the reason for appended JavaScript tag in the latter part of the question. It's because of previewing from the developer console. When I access the URL directly, Excel opens fine. – highfive Mar 12 '18 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.