[英]Why is Aspose.Cells cutting off the top half of my text when I export to PDF (or TIFF or XPS)?
I'm using Aspose.Cells to create a report to be exported to both Excel and PDF. 我正在使用Aspose.Cells创建要导出到Excel和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.
在单元格A1中,我有一些文本,字体大小为20。将工作簿保存为PDF文件时,文本的上半部分被截断。
Here's a screenshot of the PDf file: 这是PDf文件的屏幕截图:
I tried adjusting the height of the first row using AutoFitRow(int), but that's not fixing my problem. 我尝试使用AutoFitRow(int)调整第一行的高度,但这不能解决我的问题。 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.
如果我导出到Tiff或XPS,文本也会被截断。 It looks fine however if I export to XLSX.
但是,如果我导出到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: 编辑:如果单元格已合并,则需要使用AutoFitterOptions告诉代码适合合并的单元格:
ws.AutoFitRow(0, 0, 1, new Aspose.Cells.AutoFitterOptions() { AutoFitMergedCells = true });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.