Thursday, Oct. 19, 2017

Manipulating Excel with Siebel through Escript (COM Objects)

Written By:

|

June 25, 2012

|

Posted In:

COM objects allows an external application to connect and communicate with the Siebel Application Object Manager.

If you want to manipulate (Open / Create / Edit / Save) an excel file through Siebel Escript, you are going to need some methods. So here they are:

1)    To create an excel application instance:

var ExcelIns = COMCreateObject(“Excel.Application”);

2)    To create a new file:

ExcelIns.Visible = true;
ExcelIns.WorkBooks.Add();

3)    To Open an existing file:

var file = “D:\\Data.xls”;

ExcelIns.Workbooks.Open(file);

4)    To read a column value:

var value1 = ExcelIns.ActiveSheet.Cells(2,3).Value ;

5)    To write in the file:

ExcelIns.ActiveSheet.Cells(4,2).Value = “Enter your data here”;

6)    To insert a row:

ExcelIns.ActiveSheet.Rows(5).Insert;

7)    To insert a column:

ExcelIns.ActiveSheet.Columns(9).Insert;

8)    To delete a row:

ExcelIns.ActiveSheet.Rows[7].Delete

9)    To delete a column:

ExcelIns.ActiveSheet.Columns[4].Delete

10)  To Save the file:

ExcelIns.ActiveWorkbook.SaveAs (<filename>);

11)   To close the instance and release the resources:

ExcelIns.Application.Quit();

ExcelIns = null;

Hope it helps, have a good day !!



Share This Article

About Author

Rohit

Siebel Technical Consultant

  • http://www.facebook.com/prasad.sauravkumar Saurav Kumar

    Gr8 help …… but could you please add the command to save the same file … here we have to save the file in different name ExcelIns.ActiveWorkbook.SaveAs ();

  • Rohit

    Hi Saurav….If you are using VB, then the method is
    ExcelIns.ActiveSheet.Save but in escript I am not sure of the method syntax. You can try using
    ExcelIns.ActiveSheet.Save or
    ExcelIns.Workbooks.Save(file); (where file is your opened file object). If you find correct syntax in eScript, please do share…