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

VSTO style code behind

I would like to generate an xls file that has my data plus C# "code behind" in the same document so that my code will take over and add menus, etc. when my xls document is loaded. Can XLSio do this? What are my options? Thanks, Greg

5 Replies

RA Ramu Syncfusion Team December 2, 2005 01:10 PM UTC

Hi Greg, Yes. VSTO style code behind is possible in XlsIO. XlsIO preserves the menu created by VBA Code in Excel file. XlsIO allows adding data to the Excel file and save the data in Excel file. //Adds text to the first cell of spreadsheet. sheet.Range["A1"].Text ="Syncfusion"; //Saving the opened spread sheet. workbook.Save (); Please let me know if you have any questions. Thanks for your interest in Syncfusion Products. Thanks, Ramu.


ST Stefan Tsalapatis December 2, 2005 08:41 PM UTC

Hi, any sample about this ? Regards


AD Administrator Syncfusion Team December 5, 2005 07:21 AM UTC

Hi Greg/Stefan, Here is some more explanation on this issue. A combination of XlsIO and VBA Macros can be used to achieve your requirements. The part played by each component with reference to the secnario of adding a custom menu item is explained below 1) VBA VBA can be used to write code that would add a menu item and also associate action that occurs when a menu item is clicked. Please refer to this link for more information on adding custom menu items using excel VBA http://www.ozgrid.com/VBA/custom-menus.htm Here is a sample workbook which has VBA code that runs when the workbook is opened using MS Excel. Template.zip After opening the above workbook, a new menu Item called "Chart Menu" will be created. Clicking on the Chart menu>> Insert Menu >> Charts would created a Line chart for the Data range called "Chart Data". 2) XlsIO The part where XlsIO can work with VBA is by a) Inserting data dynamically into the spreadsheet. b) Redefining the named range called "Chart Data" so that the chart drawn by VBA uses the updated data range. Here is a complete working sample using VBA and XlsIO F37919CustomMenusInVBA.zip Please let me know if you have any questions. Thanks, Stephen.


ST Stefan Tsalapatis December 5, 2005 09:51 AM UTC

Thanks Stephen. As for me, I have not work yet with this issue. ( I use XLsIO for worksheets, calculations, named ranges ) I have two questions ( maybe naive). 1. Is it possible to create custom menus only with XLSIO. 2. Is it possible in worksheet created by XLSIO to link dynamically a reference to .Net Assembly and create an object. (through a menu action or a button with C# code ). For example to create a Windows Form which can do something and update the worksheet (again through XLSIO) ( and the worksheet is opened the same time ). Another question for different issue 3. When I do calcualation with XlsIO it does not save the formulas. ver. 3.2.0 There is any way to save in this version or newer. Regards Stefan


AD Administrator Syncfusion Team December 12, 2005 08:29 AM UTC

Hi Stefan, Sorry for the delay in getting back to you. 1) No, XlsIO does not have any support for creating custom menus. We also do not expect to be adding this functionality in the future due to the undocumented nature of Excel file format. 2) No, this would not be possible since XlsIO is just an object model and it does not maintain any connection with the Excel file once it serializes the object model to disk as an XLS file. The file on disk is opened by MS Excel only. I have not tried this out but this scenario should be possible a) Launch a windows form using VBA Code. b) XlsIO could be used to read the contents of the spreadsheet that is open (Just read since MS Excel locks the file and does not allow other applications opening it). However there could be no interaction possible between XlsIO and the spreadsheet that is open. 3) Are you referring to the ability to be able to calculate values of formula dynamically using XlsIO?. Please refer to this sample in version 4.1 C:\Program Files\Syncfusion\Essential Studio\4.1.0.3\Windows\XlsIO.Windows\Samples\CalculationEngine\XlsIOCalcEngine Thanks, Stephen. > >Thanks Stephen. > >As for me, I have not work yet with >this issue. >( I use XLsIO for worksheets, > calculations, named ranges ) > >I have two questions ( maybe naive). > >1. Is it possible to create custom menus only with XLSIO. > >2. >Is it possible in worksheet created >by XLSIO to link dynamically a reference to .Net Assembly and create an object. >(through a menu action or a button >with C# code ). >For example to create a Windows Form >which can do something and update >the worksheet (again through XLSIO) >( and the worksheet is opened the same time ). > > >Another question for different issue > >3. When I do calcualation with XlsIO >it does not save the formulas. >ver. 3.2.0 >There is any way to save in this version or newer. > > >Regards > >Stefan > > > > > > >

Loader.
Live Chat Icon For mobile
Up arrow icon