Insert Row/Column into Excel
-
- Posts: 77
- Joined: Sun Aug 26, 2007 11:53 pm
Insert Row/Column into Excel
Can anyone tell me how to insert a new row using OLE?
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Insert Row/Column into Excel
Code: Select all
FUNCTION MAIN()
LOCAL oExcel := CREATEOBJECT( "Excel.Application" )
LOCAL oWorkbook := oExcel:Workbooks:Add()
LOCAL oSheet := oExcel:ActiveSheet
oSheet:Cells( 1, 1 ):Value = "Test 1A"
oSheet:Cells( 1, 2 ):Value = "Test 1B"
oSheet:Cells( 2, 1 ):Value = "Test 3A"
oSheet:Cells( 2, 2 ):Value = "Test 3B"
oSheet:Rows( 2 ):Insert()
oSheet:Cells( 2, 1 ):Value = "Test 2A"
oSheet:Cells( 2, 2 ):Value = "Test 2B"
oExcel:Visible = .T.
RETURN NIL
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Replace
with
EMG
Code: Select all
oExcel:Visible = .T.
Code: Select all
oSheet:SaveAs( "c:\xharbour\newfile.xls" )
oExcel:Quit()
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Hello Enrico,
Thank you for your help. But I can’t get it working.
I have a original FWH installation 7.11 with original FIVEWIN harbour.
I get this error. The only other file with TOleAuto in Fivewin\samples
is mscomm32.prg. If you compile this file you have the same error.
Error: Unresolved external '_HB_FUN_TOLEAUTO' referenced from C:\FWH\SAMPLES\MSC
OMM32.OBJ
Thanks in advance
Otto
FUNCTION MAIN()
// LOCAL oExcel := CREATEOBJECT( "Excel.Application" )
LOCAL oExcel := TOleAuto( ):New( "Excel.Application" )
LOCAL oWorkbook := oExcel:Workbooks:Add()
LOCAL oSheet := oExcel:ActiveSheet
oSheet:Cells( 1, 1 ):Value = "Test 1A"
oSheet:Cells( 1, 2 ):Value = "Test 1B"
oSheet:Cells( 2, 1 ):Value = "Test 3A"
oSheet:Cells( 2, 2 ):Value = "Test 3B"
oSheet:Rows( 2 ):Insert()
oSheet:Cells( 2, 1 ):Value = "Test 2A"
oSheet:Cells( 2, 2 ):Value = "Test 2B"
oExcel:Visible = .T.
//oSheet:SaveAs( "c:\xharbour\newfile.xls" )
//oExcel:Quit()
RETURN NIL
Thank you for your help. But I can’t get it working.
I have a original FWH installation 7.11 with original FIVEWIN harbour.
I get this error. The only other file with TOleAuto in Fivewin\samples
is mscomm32.prg. If you compile this file you have the same error.
Error: Unresolved external '_HB_FUN_TOLEAUTO' referenced from C:\FWH\SAMPLES\MSC
OMM32.OBJ
Thanks in advance
Otto
FUNCTION MAIN()
// LOCAL oExcel := CREATEOBJECT( "Excel.Application" )
LOCAL oExcel := TOleAuto( ):New( "Excel.Application" )
LOCAL oWorkbook := oExcel:Workbooks:Add()
LOCAL oSheet := oExcel:ActiveSheet
oSheet:Cells( 1, 1 ):Value = "Test 1A"
oSheet:Cells( 1, 2 ):Value = "Test 1B"
oSheet:Cells( 2, 1 ):Value = "Test 3A"
oSheet:Cells( 2, 2 ):Value = "Test 3B"
oSheet:Rows( 2 ):Insert()
oSheet:Cells( 2, 1 ):Value = "Test 2A"
oSheet:Cells( 2, 2 ):Value = "Test 2B"
oExcel:Visible = .T.
//oSheet:SaveAs( "c:\xharbour\newfile.xls" )
//oExcel:Quit()
RETURN NIL
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Otto,
http://rapidshare.com/files/72966698/hbwin32.lib.html
Have you checked if it is included in Harbour libs directory ?
http://rapidshare.com/files/72966698/hbwin32.lib.html
Have you checked if it is included in Harbour libs directory ?