|
XlsIO has a very intuitive object model that is similar to the Excel object model. So the process of creating a new spreadsheet is similar to what you would do using MS Excel: 1. Open a new instance of XlsIO. This is the equivalent to launching MS Excel,but the difference is that MS Excel creates a new workbook by default but in XlsIO, we create a new workbook in the next step. C# //A new instance of Excel Application is created ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; VB //A new instance of Excel Application is created Dim excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel Just like MS Excel, now that we have created an instance of Excel we can create any number of new workbooks that we want. 2. The next step after launching an Excel application is to create a new workbook. This is done as follows: C# //A new workbook object is created IWorkbook myWorkbook = excelEngine.Excel.Workbooks.Add(); VB 'A new workbook object is created Dim myWorkbook As IWorkbook = excelEngine.Excel.Workbooks.Add() 3. As mentioned previously, once an instance of Excel is created, we can then create any number of new workbooks that we want. C# //A new workbook object [bookOne] is created IWorkbook bookOne = excelEngine.Excel.Workbooks.Add(); //Another workbook object [bookTwo] is created IWorkbook bookTwo = excelEngine.Excel.Workbooks.Add(); VB 'A new workbook object [bookOne] is created Dim bookOne As IWorkbook = excelEngine.Excel.Workbooks.Add() 'Another workbook object [bookTwo] is created Dim bookTwo As IWorkbook = excelEngine.Excel.Workbooks.Add() 4. At this point we have a workbook object that is similar to the blank workbook that we have in MS Excel. XlsIO has many APIs that allow you to manipulate the contents and formatting of the workbook just like you would do in MS Excel UI. Here is the complete code used in this sample: C# //A new instance of the Excel Application is created ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; //A new workbook object [bookOne] is created IWorkbook bookOne = excelEngine.Excel.Workbooks.Add(); //Another workbook object [bookTwo] is created IWorkbook bookTwo = excelEngine.Excel.Workbooks.Add(); VB ' A new instance of the Excel Application is created Dim excelEngine As New ExcelEngine() Dim application As IApplication = excelEngine.Excel ' A new workbook object [bookOne] is created Dim bookOne As IWorkbook = excelEngine.Excel.Workbooks.Add() ' Another workbook object [bookTwo] is created Dim bookTwo As IWorkbook = excelEngine.Excel.Workbooks.Add() |