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,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BenJenAuthor Commented:
I found the issue and corrected myself.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.