public static void AddToMultipleSheets(WorksheetPart worksheetPart, WorkbookPart workbookPart, DataTable data, int startRow) { Worksheet worksheet = worksheetPart.Worksheet; string Id = workbookPart.GetIdOfPart(worksheetPart); SheetData sheetData = worksheet.Descendants<SheetData>().FirstOrDefault(); UInt32Value rowIndex = (UInt32Value)((UInt32)startRow); for (int rIndex = 0; rIndex < data.Rows.Count; rIndex++) { Row row = new Row() { RowIndex = rowIndex++, Spans = new ListValue<StringValue>() { InnerText = "1:3" }, DyDescent = 0.25D }; for (int cIndex = 0; cIndex < data.Columns.Count; cIndex++) { Cell cell = new Cell() { CellReference = ColumnCaption.Instance.Get((Convert.ToInt32((UInt32)rowIndex) - 2), cIndex), DataType = CellValues.String }; CellFormat cellFormat = new CellFormat(); CellValue cellValue = new CellValue(); cellValue.Text = data.Rows[rIndex][cIndex].ToString(); // My Requirement is to merge three adjacent cells. // If suppose my last column is "J" i need to merge J,K,L and value to placed in the merged cell cell.Append(cellValue); row.Append(cell); } sheetData.Append(row); // Other requirment is to delete one column from the sheet data, say "M" Column } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)