How to create excel file dynamically

Last post 11-16-2009 5:46 PM by pbb. 5 replies.

Sort Posts:

  • How to create excel file dynamically

    11-07-2009, 4:34 AM

    Hi,

    I am designing a web page in c#.net.

    In this i need to create a sample excel file programmatically from sql database.

    Plz help how can i create excel file in which column names should be created as  fields of  sql table.

    Pankaj Tiwari

  • Re: How to create excel file dynamically

    11-07-2009, 4:50 AM

    Hi,

    Get the data from the DAtabase, store it in a DataTable,

    and use the code in this post:

    http://forums.asp.net/t/1013829.aspx

    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy


  • Re: How to create excel file dynamically

    11-07-2009, 4:58 AM
    • Member
      270 point Member
    • veenag81
    • Member since 07-04-2009, 7:04 AM
    • Gandhinagar,India
    • Posts 61

    Hello, Try following links ---->

    http://www.c-sharpcorner.com/UploadFile/ggaganesh/CreateExcelSheet12012005015333AM/CreateExcelSheet.aspx

  • Re: How to create excel file dynamically

    11-08-2009, 11:49 PM
    • Member
      313 point Member
    • cnranasinghe
    • Member since 10-27-2009, 12:41 AM
    • Sri Lanka
    • Posts 81

    try this

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

  • Re: How to create excel file dynamically

    11-09-2009, 12:34 AM
    Answer
    • All-Star
      59,903 point All-Star
    • mudassarkhan
    • Member since 02-28-2008, 5:28 AM
    • Mumbai, India
    • Posts 10,551
    • TrustedFriends-MVPs
  • Re: How to create excel file dynamically

    11-16-2009, 5:46 PM
    • Member
      50 point Member
    • pbb
    • Member since 08-19-2005, 7:29 AM
    • Trondheim, Norway
    • Posts 40

    All solutions above use one of two methodes:

    1. Use COM Automation to run an instance of Excel, to create an Excel file.
    2. Create a HTML file with an ".xls" file extension.

    The problem with the first solution is that you must have Excel installed on the server. Apart from stability problems you may get from running and quitting a headless instance of Excel for every Excel file that needs to be produced, you may also breaking the license agreement because you basically put every user of your webpage "in control" of Excel.

    The second method is the one I am also commonly using. It works pretty well, except when people want to re-save the Excel file (in which case it will write a HTML file instead of an Excel file by default), or when people want to open the file in another application (neither OpenOffice.org Calc, nor Google Docs Spreadsheet recognize this "fake" Excel file).

    I know however of several other methods, for which you will find very little documentation on internet, and I do not have much experience with them myself either.

    1. Run a "headless" instance of OpenOffice.org on the server to create XLS files (can also be used to generate or convert PDF and ODT files, but has many of the same stability problems as running Excel on the server).
    2. Create Excel 2007 XMLX files (also know as Open Office XML, OOXML or SpreadsheetML files, NOT TO BE CONFUSED with OpenOffice.org XML files), which are basically just zipped XML files, but which require the user has Excel 2007 or the Office Compatibility Pack for Office 2007 File Formats installed.
    3. Use NPOI to create Excel 2003 XML files (http://npoi.codeplex.com/).
    4. Use ADOX to create Excel files: http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=52806
Page 1 of 1 (6 items)