The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
GMGeetha M Syncfusion Team June 3, 2010 04:44 AM UTC
Hi,
Thank you for your interest in Syncfusion products.
The code snippet you have used does not have any workbook initialized and thus causes exception. If you are to create a new workbook, you can make use of the following code. ExcelEngine excelEngine = new ExcelEngine(); IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1); IWorksheet sheet = workbook.Worksheets[0];
Please try this and let me know if you have any questions.
Regards, Geetha
FSFarman SameeJune 3, 2010 09:55 AM UTC
Ok thanks- does this mean that I can't access the workbook which is currently active in Excel, unless I have just created it myself using the Excel Engine object? I don't want to create the (currently open) workbook myself, the user will have opened this manually. I just want to access it, in order to add some sheets. Can I do this? (ps. please bear in mind I can't seem to access the Excel 'Application' object, if I need to do this can you let me know the full namespace). Thanks
GMGeetha M Syncfusion Team June 4, 2010 12:18 PM UTC
Hi,
Thank you for the details.
I was able to reproduce the NullReference exception when accessing ActiveWorkbook after loading a workbook. Could you please workaround this using the following code snippet? ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Open(@"..\..\Input.xlsx", ExcelOpenType.Automatic);
IWorkbook book = application.ActiveSheet.Workbook;