Salesforce Asked by sai venkat prakash on November 25, 2021
when i downloaded into system in libre office and wps office the excel file is opening but in Ms Excel the file is throwing error
<apex:page standardStylesheets="false"
id="pge"
standardController="Order"
extensions="OrderExcelGenerationController"
applyHtmlTag="false"
applyBodyTag="false"
showHeader="false"
contenttype="application/vnd.ms-excel#orderForm.xls">
{!xmlHeader}
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:m="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>8535</WindowHeight>
<WindowWidth>12345</WindowWidth>
<WindowTopX>480</WindowTopX>
<WindowTopY>90</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author></Author>
<LastAuthor></LastAuthor>
<Company></Company>
<Version>11.6360</Version>
</DocumentProperties>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="100">
<Column ss:AutoFitWidth="0" ss:Width="0" ss:Hidden="1"></Column>
<Column ss:AutoFitWidth="1" ss:Width="200"></Column>
<Column ss:AutoFitWidth="2" ss:Width="200"></Column>
<Column ss:AutoFitWidth="3" ss:StyleID="" ss:Width="150"></Column>
<Column ss:AutoFitWidth="4" ss:StyleID="" ss:Width="150"></Column>
<Column ss:AutoFitWidth="5" ss:Width="150"></Column>
<Column ss:AutoFitWidth="6" ss:Width="150"></Column>
<Column ss:AutoFitWidth="7" ss:Width="150"></Column>
<Row ss:Height="40">
<Cell><Data ss:Type="String">AUD</Data></Cell>
<Cell ss:MergeAcross="5" ss:StyleID="s1">
<Data ss:Type="String">ORDER FORM</Data>
</Cell>
</Row>
<Row ss:Height="20">
<Cell>
<Data ss:Type="String"></Data>
</Cell>
</Row>
<Row ss:Height="20">
<Cell><Data ss:Type="String">AUD</Data></Cell>
<Cell ss:MergeAcross="">
<Data ss:Type="String">HOTEL</Data>
</Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
<apex:outputText value="{!endFileXML}" escape="false" />
</apex:page>
public with sharing class OrderExcelGenerationController {
public string accountName {get;set;}
public string endfile {get;set;}
public Set<String> type {get;set;}
public String endFileXML {get;set;}
public OrderExcelGenerationController(ApexPages.StandardController controller)
{
endFileXML = '</Workbook>';
orderId=ApexPages.currentPage().getParameters().get('orderId');
//Id orderId='8010T000000D31JQAS';
order = [SELECT Id,Name,Account.Name,Account.ShippingStreet,Account.ShippingCity,Account.ShippingState,Account.ShippingPostalCode,Account.ShippingCountry FROM Order WHERE Id=:orderId];
xmlheader ='<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>';
endfile = '</Workbook>';
var result=response.getReturnValue();
let downloadLink = document.createElement('a');
downloadLink.download = result.orderFileName+'.xlsx';
downloadLink.href = 'data:application/excel;base64,'+result.orderFileContent;
downloadLink.click();
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP