Nokia Lumia 920 Excel not open

0 votes

I created a responsive website in Asp.net using C#, and it functions flawlessly on both desktop and mobile devices. However, when I download Excel for the Nokia Lumia 920, it is downloaded but does not open on the phone. It displays errors such as Incorrect format.

I have used the below-mentioned code for downloading Excel :

Response.AddHeader("content-disposition", "attachment;filename=" + ExcelFileName + ".xlsx");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringBuilder build = new StringBuilder();
//buid contain data
Response.Output.Write(build.ToString());
Response.Flush();
Response.End();

What can be the solution?

Sep 26, 2022 in Others by Kithuzzz
• 38,010 points
296 views

1 answer to this question.

0 votes

The issue is with your code, not the phone, which is in perfect working order. Since you are delivering HTML and the response's response headers are set to xlsx, the format is actually improper and not what the phone expects. On desktop, this only functions because desktop Excel is able to display HTML tables as excel sheets, however AFAIK, Excel 2007, and newer versions notify the user that the data is in the wrong format.

The only solution is to create a real Excel file using an excel library. Use EPPlus as an example; it's straightforward and suitable for servers. 

Here is the example of exporting ADO.NET DataTable to an excel sheet and serving it to the client :

https://stackoverflow.com/a/9569827/351383

answered Sep 27, 2022 by narikkadan
• 63,420 points

Related Questions In Others

0 votes
1 answer

How to open .xlsx files in MS Excel from VS Code?

Hello, to open xlxs files, or files ...READ MORE

answered Feb 17, 2022 in Others by gaurav
• 23,260 points
2,894 views
0 votes
1 answer

Excel VBA if file closed, then open and paste, else just paste data

Slightly re-worked to add full workbook/sheet qualifiers ...READ MORE

answered Sep 21, 2022 in Others by narikkadan
• 63,420 points
525 views
0 votes
1 answer

JavaScript API does not work for Excel 2013?

Each method in the Office.js APIs is ...READ MORE

answered Sep 26, 2022 in Others by narikkadan
• 63,420 points
365 views
0 votes
1 answer
0 votes
1 answer

Authenticate on an ASP.Net Forms Authorization website from a console app

Essentially, we need to record a regular ...READ MORE

answered Sep 20, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
572 views
0 votes
1 answer

Writing SEO friendly url gets infinite loop asp.net

you should know that regex avoid cases ...READ MORE

answered Feb 11, 2022 in Others by narikkadan
• 63,420 points
600 views
0 votes
0 answers

How to get Bitcoin value for corresponding USD value in ASP.NET C#?

I want to get the Bitcoin value ...READ MORE

Mar 1, 2022 in Blockchain by Soham
• 9,700 points
623 views
0 votes
0 answers

The request was aborted: Could not create SSL/TLS secure channel

When I connect to an  HTTPS server ...READ MORE

May 1, 2022 in Other DevOps Questions by Kichu
• 19,050 points
1,711 views
0 votes
1 answer

Excel cannot open the file because the file format or file extension is not valid - PHP Maatwebsite

Try this: if (ob_get_length() == 0 ) { ...READ MORE

answered Dec 19, 2022 in Others by narikkadan
• 63,420 points
905 views
0 votes
1 answer

Blazor - ClosedXml - excel cannot open the file beacause the file format or extension is not valid

Changed the following code: function BlazorDownloadFile(filename, bytesBase64) { var ...READ MORE

answered Jan 20, 2023 in Others by narikkadan
• 63,420 points
853 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP