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# Create Excelfile

C# Create Excelfile

Scheduled Pinned Locked Moved C#
csharphelpquestion
2 Posts 2 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 guys sorry for disturbing again.... now a new and intressting problem: I have installed now Office XP && Office 2007. If I create a new excelfile with

    worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);

    it become a ".xls" Previous I only had Office 2007 and the same code created a ".xlsx" file then I used the following code to create a ".xls":

    worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);

    I've a string with the full path, it contains which format I want to use... ("a\b\c\2003.xls" or "a\b\c\2007.xlsx")

     if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xls")
        worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
     else if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xlsx")
        worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);
     excelApp.Quit();
    

    so what could I do to save the file in the right form? :confused: greets Mschauder

    T 1 Reply Last reply
    0
    • M Mschauder

      Hey guys sorry for disturbing again.... now a new and intressting problem: I have installed now Office XP && Office 2007. If I create a new excelfile with

      worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);

      it become a ".xls" Previous I only had Office 2007 and the same code created a ".xlsx" file then I used the following code to create a ".xls":

      worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);

      I've a string with the full path, it contains which format I want to use... ("a\b\c\2003.xls" or "a\b\c\2007.xlsx")

       if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xls")
          worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
       else if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xlsx")
          worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);
       excelApp.Quit();
      

      so what could I do to save the file in the right form? :confused: greets Mschauder

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      It sounds like you have installed stuff in the wrong order. Check out this MSDN article[^] If stuff is installed in the wrong order it won't work properly. My personal experience is that although Microsoft claim you can (but not recommended) have both versions installed at the same time, in practice every piece of code you write is almost guaranteed to break.

      If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]

      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