Excel Reports
FillFromCsvString Method
Example 



KellermanSoftware.ExcelReports Namespace > ExcelReportsGenerator Class : FillFromCsvString Method
The worksheet to fill
The string to use for the data
Fill a worksheet using data from a CSV string
Syntax
Public Sub FillFromCsvString( _
   ByVal worksheet As Worksheet, _
   ByVal csvString As String _
) 
Dim instance As ExcelReportsGenerator
Dim worksheet As Worksheet
Dim csvString As String
 
instance.FillFromCsvString(worksheet, csvString)
public void FillFromCsvString( 
   Worksheet worksheet,
   string csvString
)
public:
void FillFromCsvString( 
   Worksheet^ worksheet,
   String^ csvString
) 

Parameters

worksheet
The worksheet to fill
csvString
The string to use for the data
Example
ExcelReportsGenerator generator = new ExcelReportsGenerator(); //Trial Mode
//ExcelReportsGenerator generator = new ExcelReportsGenerator("place user name here", "place license key here"); //License Mode
 
//Parameters
string filePath = "FillWorksheetWithCsvStringExample.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 = "FillWorksheetWithCsvStringExample.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