Excel Reports
FillFromCsvStream Method
Example 



KellermanSoftware.ExcelReports Namespace > ExcelReportsGenerator Class : FillFromCsvStream Method
The worksheet to fill
The stream with CSV file
Fill a worksheet using data from a CSV stream
Syntax
Public Sub FillFromCsvStream( _
   ByVal worksheet As Worksheet, _
   ByVal csvStream As Stream _
) 
Dim instance As ExcelReportsGenerator
Dim worksheet As Worksheet
Dim csvStream As Stream
 
instance.FillFromCsvStream(worksheet, csvStream)
public void FillFromCsvStream( 
   Worksheet worksheet,
   Stream csvStream
)
public:
void FillFromCsvStream( 
   Worksheet^ worksheet,
   Stream^ csvStream
) 

Parameters

worksheet
The worksheet to fill
csvStream
The stream with CSV file
Example
ExcelReportsGenerator generator = new ExcelReportsGenerator(); //Trial Mode
//ExcelReportsGenerator generator = new ExcelReportsGenerator("place user name here", "place license key here"); //License Mode
 
//Parameters
string filePath = "FillWorksheetWithCsvStreamExample.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";
 
File.WriteAllText("Input.csv",csvString);
 
using (FileStream csvStream = new FileStream("Input.csv", FileMode.Open, FileAccess.Read))
{
    generator.FillFromCsvStream(worksheet, csvStream);
}
 
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 = "FillWorksheetWithCsvStreamExample.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"
 
File.WriteAllText("Input.csv",csvString)
 
Using csvStream As New FileStream("Input.csv", FileMode.Open, FileAccess.Read)
    generator.FillFromCsvStream(worksheet, csvStream)
End Using
 
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