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. General Programming
  3. C#
  4. C# - Fill a .xlsx / .xls - file with data based on a grid

C# - Fill a .xlsx / .xls - file with data based on a grid

Scheduled Pinned Locked Moved C#
questioncsharpcss
4 Posts 4 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.
  • M Offline
    M Offline
    Mschauder
    wrote on last edited by
    #1

    Hey, I have my data in a grid (no datagridview), export a grid (30 cols and over 20.000 rows) takes a lot of time (minimum 2minutes)... X| now my question: Is there a way to accelerate this?

    for (int i = 0; i < UsingGrid.Cols; i++)
    {
    for (int j = 0; j < UsingGrid.Rows; j++)
    {
    worksheet.Cells[j + 1, i + 1] = ConvertToExcelFormat(Convert.ToString(UsingGrid[j, i]));
    }
    }

    Thank you

    T R D 3 Replies Last reply
    0
    • M Mschauder

      Hey, I have my data in a grid (no datagridview), export a grid (30 cols and over 20.000 rows) takes a lot of time (minimum 2minutes)... X| now my question: Is there a way to accelerate this?

      for (int i = 0; i < UsingGrid.Cols; i++)
      {
      for (int j = 0; j < UsingGrid.Rows; j++)
      {
      worksheet.Cells[j + 1, i + 1] = ConvertToExcelFormat(Convert.ToString(UsingGrid[j, i]));
      }
      }

      Thank you

      T Offline
      T Offline
      TheFoZ
      wrote on last edited by
      #2

      Hi Might be worth looking in to the Range.set_value method. I've used the get_value method to import a whole sheet in to an array so you should be able to do the reverse easily enough. There is an example here http://stackoverflow.com/questions/2314393/how-to-specify-format-for-individual-cells-with-excel-range-set-value[^]

      The FoZ

      1 Reply Last reply
      0
      • M Mschauder

        Hey, I have my data in a grid (no datagridview), export a grid (30 cols and over 20.000 rows) takes a lot of time (minimum 2minutes)... X| now my question: Is there a way to accelerate this?

        for (int i = 0; i < UsingGrid.Cols; i++)
        {
        for (int j = 0; j < UsingGrid.Rows; j++)
        {
        worksheet.Cells[j + 1, i + 1] = ConvertToExcelFormat(Convert.ToString(UsingGrid[j, i]));
        }
        }

        Thank you

        R Offline
        R Offline
        Rashmi_Karnam
        wrote on last edited by
        #3

        Why can't you use Response.write with Inline or attachment file type to export data from Grid to Excel.

        Rashmi.M.K

        1 Reply Last reply
        0
        • M Mschauder

          Hey, I have my data in a grid (no datagridview), export a grid (30 cols and over 20.000 rows) takes a lot of time (minimum 2minutes)... X| now my question: Is there a way to accelerate this?

          for (int i = 0; i < UsingGrid.Cols; i++)
          {
          for (int j = 0; j < UsingGrid.Rows; j++)
          {
          worksheet.Cells[j + 1, i + 1] = ConvertToExcelFormat(Convert.ToString(UsingGrid[j, i]));
          }
          }

          Thank you

          D Offline
          D Offline
          Dan Mos
          wrote on last edited by
          #4

          Check this article. It is fast.

          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