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. Visual Basic
  4. vb.net writes output to separate worksheets in separate workbooks

vb.net writes output to separate worksheets in separate workbooks

Scheduled Pinned Locked Moved Visual Basic
csharpsalestutorial
5 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.
  • J Offline
    J Offline
    jazzgirl
    wrote on last edited by
    #1

    I would like to know how to write out excel 2003 excel worksheets to separate files. Basically I need to write out each excel 2003 file generated by a vb.net 2005 desktop application to separate workbooks. Each separate worksheet is going to be email and encrypted for each customer. Thus I would appreciate any suggestions that you have how to accomplish this task. Thanks!

    D M 2 Replies Last reply
    0
    • J jazzgirl

      I would like to know how to write out excel 2003 excel worksheets to separate files. Basically I need to write out each excel 2003 file generated by a vb.net 2005 desktop application to separate workbooks. Each separate worksheet is going to be email and encrypted for each customer. Thus I would appreciate any suggestions that you have how to accomplish this task. Thanks!

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I'm assuming you already have Excel interop code written that creates the worksheet. All you do is create a new Workbook, add a new Worksheet to it, populate it, and save. Rinse and Repeat. Google results for "vb.net create new workbook"[^].

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      J 1 Reply Last reply
      0
      • D Dave Kreskowiak

        I'm assuming you already have Excel interop code written that creates the worksheet. All you do is create a new Workbook, add a new Worksheet to it, populate it, and save. Rinse and Repeat. Google results for "vb.net create new workbook"[^].

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

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

        Dave Kreskowiak: Thank you for your immediate response. However my question is can I reuse the excel object embedded in the vb.net 2005 desktop application? I need to put the output from sql server 2005 on separate spreadsheets for different customers. To accomplish this tak, it looks like I need to close and reopen the excel object each time I need to write to a new excel worksheet. Thus is there a way that I could reuse the object? Thanks!

        D 1 Reply Last reply
        0
        • J jazzgirl

          Dave Kreskowiak: Thank you for your immediate response. However my question is can I reuse the excel object embedded in the vb.net 2005 desktop application? I need to put the output from sql server 2005 on separate spreadsheets for different customers. To accomplish this tak, it looks like I need to close and reopen the excel object each time I need to write to a new excel worksheet. Thus is there a way that I could reuse the object? Thanks!

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          jazzgirl wrote:

          can I reuse the excel object

          Yes.

          jazzgirl wrote:

          it looks like I need to close and reopen the excel object each time I need to write to a new excel worksheet.

          Not true. You just close the existing workbook after you save it and create a new workbook, then add a new worksheet to it.

          jazzgirl wrote:

          is there a way that I could reuse the object?

          The simplest route, though no the most proper, would be to just create a class-level variable to hold the Excel app object, then you can use it through out the form class.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          1 Reply Last reply
          0
          • J jazzgirl

            I would like to know how to write out excel 2003 excel worksheets to separate files. Basically I need to write out each excel 2003 file generated by a vb.net 2005 desktop application to separate workbooks. Each separate worksheet is going to be email and encrypted for each customer. Thus I would appreciate any suggestions that you have how to accomplish this task. Thanks!

            M Offline
            M Offline
            Member 4320844
            wrote on last edited by
            #5

            Hi I programmed Xcell Object in VB6 , and Here is My Idea ,How it works , it may not be much different from VB-Net Code : To Read from a specific cell on the Sheet --> to a variable use following Formats : ----------------------------------------------------------------------------------- NUM = Val(Form1.Spreadsheet1.Cells(9, 5)) BRN = Val(Form1.Spreadsheet1.Cells(10, 5)) And To Write a value from a Variable to a Spesific Cell on a sheet Use Format below : ---------------------------------------------------------------------------------------- MM = 4 :' Say or any other value. Form1.Spreadsheet1.Cells(MM + 3, 1) = MM ----------------------------------------------------------------------------------------- If You are in Sheet1 and you want to send Output to sheet3 , this is Simple, Just Change the sheet # and provide the Cell adress exactly as an example see : JK ... has some value send it to sheet3 : Form1.Spreadsheet3.Cells(7, 5) = JK I hope I helped . Regards , mohamad

            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