Export dataset to excel file NOT ASP.NET

F

Franck

i'm looking or a NONE ASP.NET code. all over the web those i found
either don't work or are made for ASP.NET. Im just looking to output
dataset to excel with opening a file wich is the pseudo-template and
paste dataset info to it and save as new file.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Franck said:
i'm looking or a NONE ASP.NET code. all over the web those i found
either don't work or are made for ASP.NET. Im just looking to output
dataset to excel with opening a file wich is the pseudo-template and
paste dataset info to it and save as new file.

You can simply save it as a comma separated file (CSV) and excel will read
it ok.
Now if you want that each table be in a separated sheet you have to use
another route.
There are a lot of examples of how to do it in the web.
Also it does not matter if it's ASP.NET or not I think the code should be
the same.
 
J

James A. Fortune

This article introduces two methods about exporting data from dataset to Excel by using C#.

http://www.daniweb.com/software-development/csharp/threads/355427/151...

Here's another way. The PDC 08 Session:

PC34 - Open XML Format SDK: Developing Open XML Solutions

had a very slick demo that made use of the fact that Word 2007 (I
think it's similar for Excel 2007) now uses an open Zip format for
saving the document to bypass automation entirely. Perhaps this was
the SDK that was used for the demo:

Open XML SDK 2.0 for Microsoft Office
http://www.microsoft.com/downloads/...e5-36e9-45f5-8d8c-331df206e0d0&DisplayLang=en

I have not used it yet, but the demo was very convincing -- and it
flew! I don't think you even need Excel 2007 on your computer to
create or modify a spreadsheet using that SDK. But if you have Excel
2007, you can build basic "templates" as a starting point for the
SDK. Here's the Overview paragraph from the link:

"Open XML is an open ECMA 376 standard and is also approved as the ISO/
IEC 29500 standard that defines a set of XML schemas for representing
spreadsheets, charts, presentations, and word processing documents.
Microsoft Office Word 2007, Excel 2007, and PowerPoint 2007 all use
Open XML as the default file format.

The Open XML file formats are useful for developers because they use
an open standard and are based on well-known technologies: ZIP and
XML.

The Open XML SDK 2.0 for Microsoft Office is built on top of the
System.IO.Packaging API and provides strongly typed part classes to
manipulate Open XML documents. The SDK also uses the .NET Framework
Language-Integrated Query (LINQ) technology to provide strongly typed
object access to the XML content inside the parts of Open XML
documents.

The Open XML SDK 2.0 simplifies the task of manipulating Open XML
packages and the underlying Open XML schema elements within a package.
The Open XML Application Programming Interface (API) encapsulates many
common tasks that developers perform on Open XML packages, so you can
perform complex operations with just a few lines of code.

The tools package contains the Open XML SDK v2.0 Productivity Tool for
Office and the documentation for the Open XML SDK v2. The Open XML SDK
2.0 Productivity Tool for Microsoft Office provides a number of
features designed to improve your productivity and accelerate your
learning while working with the SDK and Open XML files. Features
include the ability to generate Open XML SDK 2.0 source code based on
document content, compare source and target Open XML documents to
reveal differences and to generate source code to create the target
from the source, validate documents, and display documentation for the
Open XML SDK v2.0, the ECMA376v1 standard, and the Microsoft Office
implementation notes."

James A. Fortune
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top