Re: Converting XML spreadsheet to native Excel in ASP.NET
From: Magdelin (magdelinsuja_at_newsgroups.nospam)
Date: 07/01/04
- Next message: Miguel Ramirez: "Re: HyperLink to webform in aspx"
- Previous message: Alek Davis: "Re: Accessing intrinsic ASP (not ASP.NET) objects from .NET class"
- In reply to: Ken Cox [Microsoft MVP]: "Re: Converting XML spread*** to native Excel in ASP.NET"
- Next in thread: Steven Cheng[MSFT]: "Re: Converting XML spread*** to native Excel in ASP.NET"
- Reply: Steven Cheng[MSFT]: "Re: Converting XML spread*** to native Excel in ASP.NET"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Jul 2004 12:59:01 -0700
Hi Ken,
Thanks for your response. I know CSV is the safest but as you know CSV does not support data formatting, headers and footers, etc. Once again datagrid works really well but I don't think it will allow me to have custom excel headers and footers. And I am not sure how relaible these third party libraries are in terms of memory management and performance. I may try using a client side script to resave the streamed XML spread*** to native excel format. Not sure if this idea will work.
Any further suggestions are welcome.
Thanks once again.
Magdelin
"Ken Cox [Microsoft MVP]" wrote:
> Hi Magdelin,
>
> For very old versions of Excel, the safest format is CSV.
>
> For older versions, you can use Datagrid HTML tables.
> http://support.microsoft.com/default.aspx?scid=kb;en-us;317719
>
> For recent versions, you can use a library like this:
> http://www.asp.net/ControlGallery/ControlDetail.aspx?Control=1977&tabindex=2
>
> If you need to go to the real Excel native format, you'll probably need a
> 3rd party component:
>
> http://www.asp.net/ControlGallery/ControlDetail.aspx?Control=1144&tabindex=2
> http://www.asp.net/ControlGallery/ControlDetail.aspx?Control=1002&tabindex=2
>
> Ken
> MVP [ASP.NET]
>
>
> "Magdelin" <magdelinsuja@newsgroups.nospam> wrote in message
> news:B672F261-1DCE-448E-BE25-6E6840319694@microsoft.com...
> > Hi,
> >
> > I have to create a report in excel from asp.net. I have the report data in
> > a dataset. I am using the following code to convert the data in dataset to
> > a XML and I transform the XML to XML spread*** with the help of XSLT.
> >
> > The below code snippet is in VB.NET though my actual implementation is in
> > C#:
> > ----------------------------------------------------------------------------------------------
> > Dim filePath As String
> > Dim fileName As String
> > filePath = context.Server.MapPath(".")
> > fileName = "Test.xls"
> >
> > ' Load the DataSet into an XmlDataDocument.
> > Dim doc As XmlDataDocument = New XmlDataDocument(ds)
> >
> > ' Create the XslTransform object and load the style***.
> > Dim xsl As XslTransform = New XslTransform
> > xsl.Load(filePath + "\\" + "Transform.xslt")
> >
> > ' Create an XPathNavigator to use in the transform.
> > Dim nav As XPathNavigator = doc.CreateNavigator()
> >
> > ' Create a FileStream object.
> > Dim fs As FileStream = New FileStream(filePath + "\\" + fileName,
> > FileMode.Create)
> >
> > ' Transform the data.
> > xsl.Transform(nav, Nothing, fs, Nothing)
> >
> > fs.Close()
> >
> > Dim contentType As String
> > contentType = "application/vnd.ms-excel"
> > context.Response.ClearContent()
> > context.Response.ClearHeaders()
> > context.Response.ContentType = contentType
> > context.Response.AddHeader("Content-Disposition",
> > "attachment;filename=" + fileName)
> > context.Response.WriteFile(filePath + "\\" + fileName)
> > context.Response.Flush()
> > context.Response.Close()
> >
> > -----------------------------------------------------------------------------------------------
> > The above code works fine but I would like to know if this solution will
> > work for any office version lesser the office XP version. I beleive XML
> > spread*** is supported only by office xp and higher.
> >
> > The reason for choosing XML spread*** and XSL is to format the report
> > data before writing it to excel file.
> >
> > Though I write the transformed XML to a file with the extension .xls, the
> > contents of the file are in still xml format. I would like to save the
> > transformed XML in native excel format. But, I do not like the idea of
> > using excel VBA since it will force me to launch the excel application in
> > unattended mode on the production web server.
> >
> > I will really appreciate if someone can give pointers to convert xml
> > spread*** file to native excel file on the web server without launching
> > an instance of excel application.
> >
> > Thank you in advance.
> >
> > Magdelin
>
>
- Next message: Miguel Ramirez: "Re: HyperLink to webform in aspx"
- Previous message: Alek Davis: "Re: Accessing intrinsic ASP (not ASP.NET) objects from .NET class"
- In reply to: Ken Cox [Microsoft MVP]: "Re: Converting XML spread*** to native Excel in ASP.NET"
- Next in thread: Steven Cheng[MSFT]: "Re: Converting XML spread*** to native Excel in ASP.NET"
- Reply: Steven Cheng[MSFT]: "Re: Converting XML spread*** to native Excel in ASP.NET"
- Messages sorted by: [ date ] [ thread ]