Hello,
I am using worksheet.Cells.DeleteBlankRows() method to delete the blank rows from the excel sheet, but its cutting some of the text. Please note that we are using Aspose total license version 21.3.0
My sample code is as below.
string dataDir = System.IO.Path.GetFullPath(@"..\..\");
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense(dataDir + "\\Aspose.Total.lic");
var loadOptions = new LoadOptions();
loadOptions.CheckExcelRestriction = false;
Workbook workbook = new Workbook(pInFile, loadOptions);
Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();
// option to set all the columns of excel in one page.
pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
pdfSaveOptions.MergeAreas = true;
/* Retain the structure of original excel */
pdfSaveOptions.ExportDocumentStructure = true;
/* Formula calculation for any digit formulla applied in excels */
/*it is best to call Workbook.CalculateFormula() just before rendering the spreadsheet to PDF.
* This ensures that the formula dependent values are recalculated, and the correct
* values are rendered in the PDF.*/
workbook.CalculateFormula();
/* For some sheet, print area is applied, to display all the data in pdf,
* below setting is needed */
foreach (Worksheet wks in workbook.Worksheets)
{
foreach (Cell cell in wks.Cells)
{
Style style = cell.GetStyle();
/* if cell is numeric, consider its category type as numeric and update the format */
if (cell.Type == CellValueType.IsNumeric &&
cell.NumberCategoryType != NumberCategoryType.Number)
{
style.SetCustom("#,##0.00", true);
}
style.VerticalAlignment = TextAlignmentType.Center;
/* set fonts */
style.Font.Name = "Helvetica";
cell.SetStyle(style);
}
wks.PageSetup.PrintArea = "";
wks.PageSetup.BottomMargin = 1;
wks.PageSetup.LeftMargin = 1;
wks.PageSetup.RightMargin = 1;
wks.PageSetup.TopMargin = 1;
wks.Cells.DeleteBlankRows();
wks.AutoFitColumns();
}
workbook.Save(pOutFile, pdfSaveOptions);
Please find original excel and converted pdf in attachment. Thank you.1538040656_1.zip (156.8 KB)