Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.
Tue Feb 06, 2018 11:05 am
Hi Guys
When converting a workbook to PDF, the saved PDF has none of wraptext style.
Setting the WrapText style- Code: Select all
x.Range["A11:K11"].Style.Font.IsBold = true;
x.Range["A11:H11"].HorizontalAlignment = Spire.Xls.HorizontalAlignType.Center;
x.Range["A11:H11"].VerticalAlignment = Spire.Xls.VerticalAlignType.Bottom;
x.Range["A11:H11"].Style.WrapText = true;
x.Range["A11:H11"].Style.Color = Color.LightGray;
x.Range["A11:H11"].Style.Font.Size = 10;
Converting and saving as PDF- Code: Select all
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape;
pdfDocument.PageSettings.Width = 1100;
pdfDocument.PageSettings.Height = 700;
PdfConverter pdfConverter = new PdfConverter(wwb);
PdfConverterSettings settings = new PdfConverterSettings();
settings.TemplateDocument = pdfDocument;
pdfDocument = pdfConverter.Convert(settings);
pdfDocument.SaveToFile(full_file_path);
Please advise if Im doing something wrong.
Versions used:PDF: 3.10.4.2040
XLS: 7.12.150.6040
Thanks
-
nicholas123
-
- Posts: 2
- Joined: Wed Dec 17, 2014 8:20 am
Wed Feb 07, 2018 2:43 am
Hello,
Thanks for your inquiry.
Kindly note that the method to convert excel to pdf you were using has been marked as obsolete, we suggest using the following method instead. And I have confirmed that the WrapText worked well with this method.
- Code: Select all
Workbook wb = new Workbook();
wb.LoadFromFile("Sample.xlsx");
Worksheet x = wb.Worksheets[0];
x.Range["A11:K11"].Style.Font.IsBold = true;
x.Range["A11:H11"].HorizontalAlignment = Spire.Xls.HorizontalAlignType.Center;
x.Range["A11:H11"].VerticalAlignment = Spire.Xls.VerticalAlignType.Bottom;
x.Range["A11:H11"].Style.WrapText = true;
x.Range["A11:H11"].Style.Color = Color.LightGray;
x.Range["A11:H11"].Style.Font.Size = 10;
x.PageSetup.Orientation = PageOrientationType.Landscape;
//Save to pdf file
wb.SaveToFile("result.pdf", Spire.Xls.FileFormat.PDF);
If there is any question, welcome to get it back to us.
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1182
- Joined: Tue Sep 27, 2016 1:06 am
Wed Feb 07, 2018 11:37 am
Thanks Nina
Everything is working correctly now.
-
nicholas123
-
- Posts: 2
- Joined: Wed Dec 17, 2014 8:20 am
Thu Feb 08, 2018 1:21 am
Hi,
Thanks for your feedback.
Please feel free to contact us if you need other assistance.
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1182
- Joined: Tue Sep 27, 2016 1:06 am