Using Linq to XML to output an Apple 'Numbers' compatible spreadsheet?

157 views Asked by At

I'm working with a (VB.NET) site that was handed to me after 5+ years of being created and maintained by another programmer. The site uses Linq to XML to generate a file as an Excel (2003) .xls file.

#Region "Download Excel"
    <Authorize()>
    Sub DownloadListForFile()
        Dim folder As String = ConfigurationManager.AppSettings("UserFiles") & "\" & UserId.ToString
        Dim file As String = "file.xls"
        Dim path As String = folder & "\" & file

        If Not (New IO.DirectoryInfo(folder)).Exists Then
            MkDir(folder)
        End If

        Dim xml = (New ReportsXML.GetXML).GetListForFile()
        xml.Save(path)

        Response.ContentType = "application/vnd.ms-excel"
        Response.Charset = ""
        Response.TransmitFile(path)
        Response.AddHeader("content-disposition", "filename=" & file)
        Response.End()
    End Sub

...

Function GetListForFile() As System.Xml.Linq.XDocument

...

Dim sml = <?xml version="1.0"?>
                  <?mso-application progid="Excel.Sheet"?>
                  <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">

...etc.

We'd like to make this site 100% iPad compatible and so far, this is the only piece holding us back. (Changing the ContentType or extension does not work. Either the file won't open in Excel or the file reads as plain-text of the XML in Numbers.)

If we could find an app that could read these files as spreadsheets, even if it's a pay app, we can do that. I'd rather find a way to make these files compatible with Numbers AND Excel if at all possible.

I've searched all over but can't seem to find a method for accomplishing this.

0

There are 0 answers