BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
private void Button_Click_1(object sender, RoutedEventArgs e)
{
GridRangeInfo range = GridRangeInfo.Rows(4, 8);
grid.ExportToExcel(range, "sample.xlsx", ExcelVersion.Excel2010);
System.Diagnostics.Process.Start("Sample.xlsx");
} |
Hi Keller,You can achieve your requirement for export the certain set of rows like below,
private void Button_Click_1(object sender, RoutedEventArgs e){GridRangeInfo range = GridRangeInfo.Rows(4, 8);grid.ExportToExcel(range, "sample.xlsx", ExcelVersion.Excel2010);System.Diagnostics.Process.Start("Sample.xlsx");}In the above sample, we have exported only the 4 to 8 rows.Regards,Jai Ganesh S
private void Button_Click_1(object sender, RoutedEventArgs e)
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Create(1); //We are using single workbook
IWorksheet sheet = workbook.Worksheets[0];
//In this case we are exporting to single ExcelSheet so we marked Worksheets as 0
var itemProperties = grid.Model.View.GetPropertyAccessProvider();
for (int i = 0; i < grid.VisibleColumns.Count; i++)
{
sheet.Range[1, i+1].Text = grid.VisibleColumns[i].MappingName;
}
var collection = grid.Model.View.Records.Where(x => (x.Data as BusinessObjects).EmployeeGender == "Male").ToList();
for (int i = 0; i < collection.Count; i++)
{
//Setting Excel cell height based on Grid Cell height
sheet.SetRowHeightInPixels(i + 2, grid.Model.RowHeights[i]);
var r = collection[i];
for (int j = 0; j < grid.VisibleColumns.Count; j++)
{
int width = Convert.ToInt32(grid.Model.ColumnWidths[j]); //Getting Grid Cell column width
sheet.SetColumnWidthInPixels(j + 1, width); //Setting Width for Excel cell
sheet.Range[i + 3, j + 1].Text =
itemProperties.GetValue(r.Data, grid.VisibleColumns[j].MappingName).ToString();
}
}
workbook.SaveAs("Sample.xls");
excelEngine.Dispose();
System.Diagnostics.Process.Start("Sample.xls");
} |