We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

RowSpan and ColSpan

Dears,

I am trying to export DataSource from server side into an excel file having a specific format ( see the attached picture )
is there any way i can do rowspan and colspan from code.
knowing that this is how i am exporting :

Workbook wbk = new Workbook();
wbk.Worksheets.RemoveAt(“Sheet1”);
Worksheet prepaidWorkSheet = wbk.Worksheets.Add(name);
#region style
Style styleTableHeader = wbk.Styles[wbk.Styles.Add()];
styleTableHeader.Font.Name = “Arial”;
styleTableHeader.Font.Size = 9;
styleTableHeader.Font.IsBold = true;
styleTableHeader.Pattern = BackgroundType.Solid;
styleTableHeader.Font.Color = Color.Black;
styleTableHeader.HorizontalAlignment = TextAlignmentType.Center;
styleTableHeader.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
styleTableHeader.Borders[BorderType.TopBorder].Color = Color.Black;
styleTableHeader.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
styleTableHeader.Borders[BorderType.BottomBorder].Color = Color.Black;
styleTableHeader.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
styleTableHeader.Borders[BorderType.LeftBorder].Color = Color.Black;
styleTableHeader.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
styleTableHeader.Borders[BorderType.RightBorder].Color = Color.Black;
#endregion
var groupedData = Data.GroupBy(t => t.Date).Select(group => new { day = group.Key, Items = group.ToList() }).ToList();
int Irow = 0;
foreach (var elt in groupedData.OrderBy(d => d.day))
{
Irow++;
prepaidWorkSheet.Cells[Irow, 0].SetStyle(cellStyle);
prepaidWorkSheet.Cells[Irow, 0].PutValue(elt.day.ToString(“dd-MMM-yyyy”));
prepaidWorkSheet.Cells[Irow, 1].SetStyle(cellStyle);
prepaidWorkSheet.Cells[Irow, 1].PutValue(sum);
}
using (MemoryStream ms = wbk.SaveToStream())
{
log.Info(“Finished Creating Sheet”);
prepaidWorkSheet.Cells.Clear();
prepaidWorkSheet = null;
wbk = null;
return ms.ToArray();
}

Hi Zeinab,


Thank you for contacting Aspose support.

Please note that the RowSpan & ColumnSpan in terms of Excel spreadsheet means to extend the cell to more than one row and/or column. If this is what you are looking for then you can use the Cells.Merge method as discussed in the detailed article on Merging & Unmerging Cells. If you meant something else then please share a sample spreadsheet showing your desired results, that you may create manually using Excel application, and share it here for better understanding of your requirements.