Excel Reports
WorkbookFactory Method
Example 



KellermanSoftware.ExcelReports Namespace > ExcelReportsGenerator Class : WorkbookFactory Method
Creates a new Workbook In Memory
Syntax
Public Function WorkbookFactory( _
   ByVal filePath As String _
) As Workbook
Dim instance As ExcelReportsGenerator
Dim filePath As String
Dim value As Workbook
 
value = instance.WorkbookFactory(filePath)
public Workbook WorkbookFactory( 
   string filePath
)
public:
Workbook^ WorkbookFactory( 
   String^ filePath
) 

Parameters

filePath

Return Value

Instantiated Workbook
Example
ExcelReportsGenerator generator = new ExcelReportsGenerator(); //Trial Mode
//ExcelReportsGenerator generator = new ExcelReportsGenerator("place user name here", "place license key here"); //License Mode
 
//Parameters
string filePath = "WorkbookFactoryExample.xlsx";
 
Workbook workbook= generator.WorkbookFactory(filePath);
 
workbook.Author = "John Smith";
workbook.CreatedTime = DateTime.Now;
workbook.LastSavedBy = "John Smith";
workbook.Subject = "This is a subject";
workbook.Title = "This is a title";
 
Worksheet worksheet = generator.AddWorksheet(workbook, "Employees");
 
string csvString = @"FirstName,LastName,Married,NumberOfChildren,Salary,BirthDate
John,Smith,True,3,""$60,000"",12/15/1977
Joe,Jones,False,0,""$30,000"",6/25/1993";
 
generator.FillFromCsvString(worksheet, csvString);
generator.SaveWorkbook(workbook);
Dim generator As New ExcelReportsGenerator() 'Trial Mode
'Dim generator As New ExcelReportsGenerator("place user name here", "place license key here") 'License Mode
 
'Parameters
Dim filePath As String = "WorkbookFactoryExample.xlsx"
 
Dim workbook As Workbook= generator.WorkbookFactory(filePath)
 
workbook.Author = "John Smith"
workbook.CreatedTime = Date.Now
workbook.LastSavedBy = "John Smith"
workbook.Subject = "This is a subject"
workbook.Title = "This is a title"
 
Dim worksheet As Worksheet = generator.AddWorksheet(workbook, "Employees")
 
Dim csvString As String = "FirstName,LastName,Married,NumberOfChildren,Salary,BirthDate" & ControlChars.CrLf & "John,Smith,True,3,""$60,000"",12/15/1977" & ControlChars.CrLf & "Joe,Jones,False,0,""$30,000"",6/25/1993"
 
generator.FillFromCsvString(worksheet, csvString)
generator.SaveWorkbook(workbook)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ExcelReportsGenerator Class
ExcelReportsGenerator Members