I'm using Aspose.Cells to create a report to be exported to both Excel and PDF. In cell A1, I have some text that I've given a font size of 20. When I save this workbook to a PDF file, the top half of the text is getting cut off.
Here's a screenshot of the PDf file:
I tried adjusting the height of the first row using AutoFitRow(int), but that's not fixing my problem. My code to reproduce this is very short:
static void Main(string[] args)
{
Program.Licenses(); //only sets licenses
var wb = new Aspose.Cells.Workbook();
var ws = wb.Worksheets[0];
var cell = ws.Cells[0, 0];
cell.Value = "Text is cutoff";
var style = cell.GetStyle();
style.Font.Size = 20;
cell.SetStyle(style);
ws.AutoFitRow(1); //doesn't prevent text cutoff
wb.Save(@"C:\Users\guest\Desktop\file2.pdf", Aspose.Cells.SaveFormat.Pdf);
}
What am I doing wrong that is causing the top half of my text to be cutoff? the text is also getting cut off if I export to Tiff or XPS. It looks fine however if I export to XLSX.
Version Information:
This line was the problem:
ws.AutoFitRow(1); //doesn't prevent text cutoff
The argument should be zero, not one. If I change that to the below, it'll work.
ws.AutoFitRow(0);
Edit: If the cells are merged, you need to use AutoFitterOptions to tell the code to fit merged cells:
ws.AutoFitRow(0, 0, 1, new Aspose.Cells.AutoFitterOptions() { AutoFitMergedCells = true });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.