Friday, September 01, 2006

Yet another way of exporting to Excel file from HTML without Excel

Yes, many of solutions of exporting to Excel from HTML should using Excel.exe process, it's a perfect way to access Excel model but with a hard problem that handling the Excel.exe process at web server side. while some few ways without Excel is too simple, indeed, is XML format file.

There is yet another way to treat the data as Excel format without Excel now.

At HTML code:

<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>
<!-- work sheet name -->
</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo />
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
<body>
<!-- data to export -->
</body>
</html>

At the server script code:



Response.ContentType = "application/vnd.ms-excel"

That's all! as you see, the key of this way is using XSD to access the Excel model.


Hope helps.


PS: this blog written by Window Live Writer, and code height light by Steve Dunn's Code Formatter Plugin.

No comments: