vb.net writes output to separate worksheets in separate workbooks
-
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!
-
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!
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 -
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, 2008Dave 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!
-
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!
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 -
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!
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