Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to create MX Excel file from DataTable?

How to create MX Excel file from DataTable?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomtutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tesic Goran
    wrote on last edited by
    #1

    Hi, I need to create MS Excel file from DataTable in ASP.NET application. I don't need "SaveAs" dialog. Just create a file and save them to some folder. I've searched the internet and found some examples how to do that by using Microsoft Excel Interop library. But, I can't use Excel Interop library. Is there any other way to do it? Thank you in advance. Goran

    A J 2 Replies Last reply
    0
    • T Tesic Goran

      Hi, I need to create MS Excel file from DataTable in ASP.NET application. I don't need "SaveAs" dialog. Just create a file and save them to some folder. I've searched the internet and found some examples how to do that by using Microsoft Excel Interop library. But, I can't use Excel Interop library. Is there any other way to do it? Thank you in advance. Goran

      A Offline
      A Offline
      AContractor
      wrote on last edited by
      #2

      Take a look at Export DataTable to Excel with Formatting in C#. It should be a good starting point.

      1 Reply Last reply
      0
      • T Tesic Goran

        Hi, I need to create MS Excel file from DataTable in ASP.NET application. I don't need "SaveAs" dialog. Just create a file and save them to some folder. I've searched the internet and found some examples how to do that by using Microsoft Excel Interop library. But, I can't use Excel Interop library. Is there any other way to do it? Thank you in advance. Goran

        J Offline
        J Offline
        Jasmine2501
        wrote on last edited by
        #3

        If you don't need special formatting or formulas then just drop the file as CSV. Excel will open CSV files with or without column names as the first row. Your question doesn't include any requirements that aren't met by a CSV file. And yes, I agree, using the Office Interop stuff is horrifying - I wrote an article about it years ago, and I still get questions on that article today. It's pretty tricky.

        T 1 Reply Last reply
        0
        • J Jasmine2501

          If you don't need special formatting or formulas then just drop the file as CSV. Excel will open CSV files with or without column names as the first row. Your question doesn't include any requirements that aren't met by a CSV file. And yes, I agree, using the Office Interop stuff is horrifying - I wrote an article about it years ago, and I still get questions on that article today. It's pretty tricky.

          T Offline
          T Offline
          Tesic Goran
          wrote on last edited by
          #4

          Yes. We can create CSV file instead of XLS. But, there's only one thing that could be a little bit undesired - wizard that opens CSV file. I'm not sure, but I think MS Excel cannot open CSV file directly without using wizard. Is that right?

          A 1 Reply Last reply
          0
          • T Tesic Goran

            Yes. We can create CSV file instead of XLS. But, there's only one thing that could be a little bit undesired - wizard that opens CSV file. I'm not sure, but I think MS Excel cannot open CSV file directly without using wizard. Is that right?

            A Offline
            A Offline
            AContractor
            wrote on last edited by
            #5

            Nope. Excel can open a CSV file directly. :-D

            J 1 Reply Last reply
            0
            • A AContractor

              Nope. Excel can open a CSV file directly. :-D

              J Offline
              J Offline
              Jasmine2501
              wrote on last edited by
              #6

              Right, and any of those security dialogs that come up - the users don't even notice that stuff. Even if the conversion wizard does come up, the users probably won't care. They complete those tasks by rote - it's a bad habit really, but it's not a huge interruption to their day. Which is not to say you shouldn't worry about it - it's a legitimate concern, but it's not as big a problem as we sometimes think.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups