• manpreetsaini26
  • NEWBIE
  • 15 Points
  • Member since 2015
  • Mr.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

I am exporting a vf page containing html table to excel (.xls) format. But when I open the excel file it gives this warning: "The file format and extension of filename.xls don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway? Yes or No". Now if I press Yes the file opens and has the data as expected. But I don't want the warning to be shown. Here's the code that I have used to export the excel file.

VF Page:

<apex:page standardController="Case" extensions="MyController" action="{!exportExcel}" readOnly="true" contentType="application/vnd.ms-excel#cases.xls" sidebar="false" cache="true">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	</head>
	<table border="1">
		{!header}
		{!excelString}
	</table>
</apex:page>
Apex class code:
public void exportExcel(){
          header ='<tr><td>'+Label1+'</td><td>'+Label2+'</td><td>'+Label3+''</td></tr>';
          excelString = '';
          for(wrapper w : getExportResultsWrapper()){
              excelString += '<tr><td>'+w.CaseNumber+'</td><td>'+w.Type+'</td><td>'+w.ReceivedDate+'</td></tr>';
        }
    }
Why is the warning coming up? What is the best way to avoid the warning? Please help...
Hi, 
Here my doubt is i want to convert the number to text format. 
here i used to TEXT(numberfield) in the formula field. but it is not working.
Ex: when a user enters 100 then the text format of the field has to display ONE HUNDRED. 

Please help me..

Thanks and Regards,
Anji reddy k

I am exporting a vf page containing html table to excel (.xls) format. But when I open the excel file it gives this warning: "The file format and extension of filename.xls don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway? Yes or No". Now if I press Yes the file opens and has the data as expected. But I don't want the warning to be shown. Here's the code that I have used to export the excel file.

VF Page:

<apex:page standardController="Case" extensions="MyController" action="{!exportExcel}" readOnly="true" contentType="application/vnd.ms-excel#cases.xls" sidebar="false" cache="true">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	</head>
	<table border="1">
		{!header}
		{!excelString}
	</table>
</apex:page>
Apex class code:
public void exportExcel(){
          header ='<tr><td>'+Label1+'</td><td>'+Label2+'</td><td>'+Label3+''</td></tr>';
          excelString = '';
          for(wrapper w : getExportResultsWrapper()){
              excelString += '<tr><td>'+w.CaseNumber+'</td><td>'+w.Type+'</td><td>'+w.ReceivedDate+'</td></tr>';
        }
    }
Why is the warning coming up? What is the best way to avoid the warning? Please help...