|
-
Sep 11th, 2002, 11:26 PM
#1
Thread Starter
Hyperactive Member
VB.NET to VC#
Dim a As New Excel.Application()
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
wb = a.Workbooks.Open("C:\book1.xls")
ws = wb.Worksheets.Item(1)
With ws
'populate titles
.Cells(1, 1).value = "Date"
.Cells(1, 2).value = "Location"
.Cells(2, 1).value = YOUR STRING VALUE
.Cells(2, 2).value = YOUR STRING VALUE
I need the above code converted to VC#. Can anyone help me with this?
-
Sep 12th, 2002, 02:41 AM
#2
Hyperactive Member
I cant really test it now but this is the conversion
static void main
{
Excel.Application a = new Excel.Application;
Excel.Workbook wb = a.Open("C:\book1.xls");
Excel.Worksheet ws = wb.Worksheets.Item(1);
ws.Cells(2, 1).value = "YOUR STRING VALUE";
ws.Cells(2, 2).value = "YOUR STRING VALUE";
}
hth
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Sep 12th, 2002, 05:49 AM
#3
Thread Starter
Hyperactive Member
Excel.Application a = new Excel.Application;
Excel.Workbook wb = a.Open ("C:\book1.xls");
Excel.Worksheet ws = wb.Worksheets.Item (1);
ws. Cells (2, 1).value = "YOUR STRING VALUE";
ws. Cells( 2, 2).value = "YOUR STRING VALUE";
I get error on the underlined codes.
-
Sep 12th, 2002, 07:51 AM
#4
Hyperactive Member
What is the error and did you set a reference to the excel runtime library ?
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
-
Sep 12th, 2002, 09:05 AM
#5
Hyperactive Member
+++++++++++++
Excel.Application a = new Excel.Application;
Excel.Workbook wb = a.Open ("C:\book1.xls");
Excel.Worksheet ws = wb.Worksheets.Item (1);
ws. Cells (2, 1).value = "YOUR STRING VALUE";
ws. Cells( 2, 2).value = "YOUR STRING VALUE";
I get error on the underlined codes.
+++++++++++++
Try this
=========================
Excel.Application a = new Excel.Application;
Excel.Workbook wb = a.Workbooks.Open (@"C:\book1.xls");
Excel.Worksheet ws = wb.Worksheets.Item [1];
ws.Range("A1").value = "YOUR STRING VALUE";
=========================
Like I said, I dont have a C# compiler to test it right now. If this still doesnt work, post this code snippet in the C# forum and ask for help there
William T
Software Architect / Chief Software Developer
Softwaremaker.Net Pte Ltd
http://www.Softwaremaker.net
*** Things are always the darkest before they go pitch black ***
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|