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. Exporting to Excel using C# and Visual Studio 2005

Exporting to Excel using C# and Visual Studio 2005

Scheduled Pinned Locked Moved C#
csharpvisual-studiodata-structureshelptutorial
1 Posts 1 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.
  • L Offline
    L Offline
    laura1316
    wrote on last edited by
    #1

    Hi All, I have created a project that exports data to Excel. I take some samples and display it using excel. I have 4 columns: time, X, Y, Z data. The X,Y,Z data is integer data and exports perfectly. The time column doesn't work. I create the array and then I try to export it, but for some reason with double it changes all the array to the first time value .1s and if I have it as a string instead it changes all the values in the array to the final read value. Does anyone know how to display the time. I am taking a sample every 100ms so I am trying to do an elapsed timer. Please help. Below is my export to excel function: private void button2_Click(object sender, EventArgs e) { timerTakeData.Enabled = false; radioButton10.Enabled = true; radioButton100.Enabled = true; radioButton20.Enabled = true; radioButton200.Enabled = true; radioButton50.Enabled = true; button1.Enabled = true; labelTime.Text = "0.00"; Excel.Workbooks ExcelBooks; Excel.Sheets ExcelSheets; Excel._Worksheet ExcelSheet; Excel.Range range; timerTakeData.Enabled = false; radioButton10.Enabled = true; radioButton100.Enabled = true; radioButton20.Enabled = true; radioButton200.Enabled = true; radioButton50.Enabled = true; button1.Enabled = true; labelTime.Text = "0.00"; Excel.Workbooks ExcelBooks; Excel.Sheets ExcelSheets; Excel._Worksheet ExcelSheet; Excel.Range range; try { // Instantiate Excel and start a new workbook. ExcelApp = new Excel.Application(); ExcelBooks = ExcelApp.Workbooks; ExcelBook = ExcelBooks.Add(Missing.Value); ExcelSheets = ExcelBook.Worksheets; ExcelSheet = (Excel._Worksheet)ExcelSheets.get_Item(1); ExcelSheet.Cells[1, 1] = "Time"; ExcelSheet.Cells[1, 2] = "X A/D"; ExcelSheet.Cells[1, 3] = "Y A/D"; ExcelSheet.Cells[1, 4] = "Z A/D"; ExcelSheet.get_Range("A1", "D1").Font.Bold = true; ExcelSheet.get_Range("A1", "D1").VerticalAlignment = Excel.XlVAlign.xlVAlignCenter; range = ExcelSheet.get_Range("A2", Missing.Value); range = range.get_Resi

    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