asp.net - how to add dataset to worksheet using Excellibrary -


I have to add multiple worksheets to a single file. I can not find a way to add dataset to the worksheet but I know

Try it out to add a worksheet.

  using the system; Using System.Data; Using System.IO; Using ExcelLibrary.SpreadSheet; Namespace Excel Library {/// & lt; Summary & gt; /// Excel provides a simple way to convert the workbook to DataSet /// & lt; / Summary & gt; Public Sealed Class Dataset Helper {/// & lt; Summary & gt; /// In all worksheets from a given Excel workbook, /// all data (converted in all strings) /// & lt; / Summary & gt; /// & lt; Param name = "filePath" & gt; File path of excel workbook & lt; / Param & gt; /// & lt; Returns & gt; Datasets populate in Dataset with all worksheets & lt; / Returns & gt; Public statusetetsetetsetset (string filpto) {dataset ds = new dataset (); Workbook workbook = workbook Load (file path); Worksheets (worksheets in workbook) {datatable dt = populated data (ws); Ds.Tables.Add (DT); } Return DS; } /// & lt; Summary & gt; /// Arrange the work sheet name in a new example of data from a given Excel /// workbook (converted in all strings) and a new example of datatale. /// If the work sheet has been given, it receives zero. /// & lt; / Summary & gt; /// & lt; Param name = "filePath" & gt; File path of excel workbook & lt; / Param & gt; /// & lt; Param name = "sheetName" & gt; Worksheet in Workbook & lt; / Param & gt; /// & lt; Returns & gt; DataSetABL data with data & lt; / Returns & gt; Public static datatable CreateDataTable (string filespath, string sheets) {workbook workbook = workbook. Load (file path); Foreign Worksheets (Worksheets in Workbook) {if (ws.Name.Equals (sheetName)) returns PopulateDataTable (ws); } Return tap; } Private Static Datable Populate DataTable (worksheet ws) {cell collection cell = V. // Creates a data sheet from a worksheet / All values ​​strings will be treated as datatable dt = new datatile (ws.Name); // Extract column for (int i = 0; i & lt; = Cells.LastColIndex; i ++) dt.Columns.Add (cell [0, i]. Stringvalue, typef (string)); // For Extra Data (Int presentRONDEX = 1; ONLINE INDEX & lt; = Cells.LastRowIndex; currentRowIndex ++) {DataRow dr = dt.NewRow (); (Int current column index = 0; current code index & lt; = Cells.LastColIndex; current code indices ++) Dr. [current column index] = cell [currentro index, current column index]. Stringsvalue; Dt.Rows.Add (Dr.); } Return DT; } /// & lt; Summary & gt; /// Populate all the data from the given dataset in a new Excel workbook & /// & lt; / Summary & gt; /// & lt; Param name = "filePath" & gt; File path to create new Excel workbook & lt; / Param & gt; /// & lt; Param name = "dataset" & gt; Source dataset & lt; / Param & gt; Public static zero CreateWorkbook (string filpto, dataset dataset) {If (dataset.Tables.Count == 0) Exceptions to new logic ("Datasets should have at least one datatylet", "dataset"); Workbook workbook = new workbook (); Forwarding (DataTable DT Tables in Datasets) {Worksheet Worksheet = New Worksheet (DTTABNAM); (Int i = 0; i   

By style and color

  HSSFCellStyle style1 = hssfworkbook.CreateCellStyle (); // cell background style1 FulFireground Corollar = NPOI.HSSF.UTLHSSFCLLRLL.ExX; Style 1 Fill pattern = HSSFCellStyle.SOLID_FOREGROUND; // font color HSSF font font1 = hssfworkbook.CreateFont (); Font1.Color = NPOI.HSSF.Util.HSSFColor.YELLOW.index; Style1.SetFont (font1); Cell.CellStyle = style1;   

See this post for more information

Comments

Popular posts from this blog

python - Assemble mpeg file unable to play in mediaplayer -

c# - crystal report failed -

mongodb - CakePHP paginator ignoring order, but only for certain values -