DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Oct 2006

    Exporting to Excel from SQL via ASP.NET...preserving HTML formatting?

    I am trying to export to Excel from SQL. My problem is not actually getting the export to work, but preserving the HTML formatting present in the SQL tables I am pulling from. When I export to Excel, either via a Datagrid bound w/the data or a custom function I have written which dumps to .csv, it goes through correctly but garbage characters appear every time a bullet point or some other non-standard formatting was present in the table.

    I know this formatting has been preserved in SQL so it's still there, it's just not making it through to the spreadsheet. I have tried doing a manual export in SQL Enterprise Manager to a text file and surprisingly the bullets and other such formatting were preserved there. I just don't know why it won't show up in Excel. Actually when I loaded that text file into Excel the bullet points did make it through in that case, but they still don't when I dump to .csv or export from a Datagrid to Excel.

    I am using ASP.NET 1.x and SQL 2000. When I export to .csv, I am first putting all the data into a custom datatable, then writing the contents of that datatable using a streamwriter.

  2. #2
    Join Date
    Jun 2004
    try opening the excel file that you get as export from your Web page and open it in Notepad.
    When we write code to write the datagrid on the page as while making the content type as excel, it doesn't actually create an excel file but creates HTML tables from datagrid and opens them in a file which has extension of XLS (or at least that is what it did a while ago for my apps). But I am very sure the XLS/CVS file that you are getting from your Web page contains HTML table and see how the formatting tags (bold, bullets so on) are showing up. that might give you an idea what you can do to fix the problem. Hope this helps.
    new to programming but getting ther

Similar Threads

  1. Replies: 0
    Last Post: 05-29-2007, 01:38 PM
  2. Replies: 1
    Last Post: 02-25-2007, 07:48 AM
  3. Replies: 0
    Last Post: 12-20-2006, 08:50 AM
  4. Including reused HTML in ASP.NET
    By Micah Nasarow in forum ASP.NET
    Replies: 1
    Last Post: 11-14-2001, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.