We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Launching Excel workbook in an existing running instance of MSExcel

I'm wondering if it is possible to do the above either in ExcelIO or ExcelRW. My experience is that the call to
ExcelEngine e = new ExcelEngine();
always creates a new instance of the application and opens the workbook inside that. Any tweaks or undocumented features that could help?


13 Replies

YG Yavanaarasi G Syncfusion Team August 14, 2008 10:41 AM UTC

Hi Swamidas,

Thank you for your interest in Syncfusion products.

If your intention is to open the excel file through XlsIO which is already opened you can use "openreadonly" method.

Here is the code snippet:

[C#]
IWorkbook myWorkbook = excelEngine.Excel.Workbooks.OpenReadOnly("Test.xls");


Also, please refer the below codesnippet to know how to add workbooks in Excelengine.


// New instance of XlsIO is created.[Equivalent to launching MS Excel with no workbooks open].

// The instantiation process consists of two steps.

// Step 1: Instantiate the spreadsheet creation engine.

ExcelEngine excelEngine = new ExcelEngine();

// Step 2: Instantiate the excel application object.

IApplication application = excelEngine.Excel;

//A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
// The number of default worksheets is the application setting in MS Excel.
IWorkbook workbook = application.Workbooks.Add();


If I have misunderstood your requirement, could you please explain me in detail, so that I will provide you a better solution?

Regards,
G.Yavana





SD Swamidas Dalvi August 14, 2008 07:24 PM UTC

Yes you've misunderstood. I have a running instance of MSExcel app open on my desktop and I'm concurrently running my own software which uses ExcelRW to launch a generated excel report in a new instance of MSExcel app. Is there any way to get the report opened in the already open instance like a child form of the MDI app? This will enable me to view it alongside other open Excel documents in the same instance of Excel via Window -> Arrange menu for Tiled, Horizontal, Vertical or Cascade options.



AD Administrator Syncfusion Team August 18, 2008 03:32 PM UTC

I'll appreciate a conclusive answer to this issue. Could someone help with this?



YG Yavanaarasi G Syncfusion Team August 19, 2008 12:18 PM UTC

Hi Swamidas,

By default, the file will be open with the already opened Excel workbook. And currently we do not have options like Arrange menu. We have logged a feature request[#3129] regarding this issue. We will update you once the feature has been implemented.

Please let me know if you have any other concerns.

Regards,
G.Yavana



SD Swamidas Dalvi August 19, 2008 02:53 PM UTC

Are you saying this is true of XlsIO and ExcelRW both? I'm positive that this is not the default behavior that I've observed with ExcelRW so you must be talking about XlsIO. Please confirm if I've understood correctly.



SD Swamidas Dalvi August 19, 2008 02:59 PM UTC

Just wanted to confirm that I'm still talking about the "launching in existing Excel instance" issue. I don't care whether your product supports the "Arrange" option - that is not what I'm looking for as it is already available in Excel which the user can manually apply.



YG Yavanaarasi G Syncfusion Team August 20, 2008 11:10 AM UTC

Hi Swamidas,

Thank you for your update.

Currenlty XlsIO do not provide support for open the excel file with the already opened Excel workbook. By default if the Ms Excel file is already opened and you have open the file in XlsIO, it automatically opens with the already opened workbook.

Please let me know if you have any other concerns.

Regards,
G.Yavana



SD Swamidas Dalvi August 20, 2008 07:22 PM UTC

Would you be able to comment if this behavior was available in ExcelRW? That is what I'm using and would like help with instead of XlsIO.



YG Yavanaarasi G Syncfusion Team August 21, 2008 09:52 AM UTC

Hi Swamidas,

ExcelRW is same as XlsIO, it is the name which is specified previously. As I have mentioned earlier XlsIO or[ExcelRW] do not provide support for getting the report with the already opened Excel workbook.At first you have open an Excel workbook through Ms Excel, before opening the file with ExcelRW. Then you can get the report opened in the already opened Excel workbook.

Please try this and let me know if you have any other concerns.

Regards,
G.Yavana




SD Swamidas Dalvi August 21, 2008 04:24 PM UTC

Yavana,
I'm unable to follow your writing. Let me confirm my understanding of your writing sentence for sentence :

You wrote: ExcelRW is same as XlsIO, it is the name which is specified previously.
I understand: They are both the same. It is just that XlsIO supports .Net 2.0 while ExcelRW supports .Net 1.1 and previous .net versions.

You wrote: As I have mentioned earlier XlsIO or[ExcelRW] do not provide support for getting the report with the already opened Excel workbook.
I understand: What you are trying to say is that it cannot read or write to a file that is already open under Excel. This isn't what I'm trying to do.


You wrote: At first you have open an Excel workbook through Ms Excel, before opening the file with ExcelRW. Then you can get the report opened in the already opened Excel workbook.
I understand: Ok. Let me rework my approach to this and see if it works.



YG Yavanaarasi G Syncfusion Team August 22, 2008 01:08 PM UTC

Hi Swamidas,

Your understanding is correct. But XlsIO have the code library for creating the files and save the file in the disk. We do not have support for open the file directly. XlsIO opens the file through .net only. We can view the file only through viewer. Hence my sentence for second secenerio is we do not open the files directly by side by side.

Regards,
G.Yavana



FP Frederic Prevost September 4, 2008 04:15 PM UTC

Hello,

XlsIO is a tool designed to manipulate XLS file without the need of Excel on the Workstation.

So, if you want to open every XLSIO generated XLS file into the same Excel instance, you can instanciate Excel an store a ref to it into a static Field. After that you have to pilot this Excel instance using OLE-Automation to open file.

Becarefull to memory or Automation problems

Regards,



GM Geetha M Syncfusion Team September 8, 2008 01:45 PM UTC

Hi,

Thank you for the update.

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon