• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 921
  • Last Modified:

Exporting to Excel MAC/Safari Issue - Blank Document


I am having an issue getting  report HTML to export to excel on MAC/Safari.

The export works perfectly fine on a PC, our client however is largely MAC based and gets a blank excel when trying to export.

Below is the code being used to export:

        Dim str As String = ""
        Dim path As String = Server.MapPath("css/global.css")
        Dim CssString As String = ""

        CssString = File.ReadAllText(path)

        Dim sw As New StringWriter()
        Dim htmlWriter As New HtmlTextWriter(sw)

        Dim html As String = "<html><head><style> " + CssString + " </style></head><body>"   + PrintHeader + "<div align=""center""> " + str + "</div><br/><br/><div align=""center"">" + PrintCopyright + "</div></body></html>"

        Response.ContentType = "application/vnd.ms-excel"
        Response.AddHeader("content-disposition", "attachment; filename= Benchmarking Toolkit Report " + Date.Now().ToShortDateString + ".xls")

Open in new window

As stated this exports fine on a PC but not on MAC or Safari, they get only get a blank excel.
The report generates less than 2000 rows in excel.

Help is much appreciated,

  • 2
1 Solution
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Change the html so you are just building a table and not div's.  I do the same thing and never had an issue. If you just need data in excel and not formatted, then create a csv file instead. All you need to do is add a comma between the fields and enclose in quotes.  Add a vbcrlf at the end of the row.
BenJenAuthor Commented:
There was apparently something about the CSS that it did not like, I removed all css but what was completely necessary for the excel portion and it seems to work now.

BenJenAuthor Commented:
I found the issue and corrected myself.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now