// Create a pdf file stream using FileStream outputStream = new FileStream("ShrinkToFitForWrappedText.pdf", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.PageSetup.PrintGridlines = true; worksheet.PageSetup.PrintHeadings = true; //"A1" is ordinary wrapped text. worksheet.Range["A1"].WrapText = true; worksheet.Range["A1"].Value = "Document Solutions for Excel"; worksheet.Range["A1"].RowHeight = 42; worksheet.Range["A1"].ColumnWidth = 9; //The wrapped text "A2" will be shrink to fit. worksheet.Range["A2"].WrapText = true; worksheet.Range["A2"].ShrinkToFit = true; worksheet.Range["A2"].Value = "Document Solutions for Excel"; worksheet.Range["A2"].RowHeight = 32; //You must create a pdfSaveOptions object before using ShrinkToFitSettings. PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); //Shrink the wrapped text within the cell with existing row height/column width, while exporting to PDF. pdfSaveOptions.ShrinkToFitSettings.CanShrinkToFitWrappedText = true; //Set minimum font size with which the text should shrink. //pdfSaveOptions.ShrinkToFitSettings.MinimumFont = 10; //If after setting the minimum font size, the text is very long not fully visible, the ellipsis string to show for long text. //pdfSaveOptions.ShrinkToFitSettings.Ellipsis = "~"; //Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions);
' Create a pdf file stream Dim outputStream = File.Create("ShrinkToFitForWrappedText.pdf") ' Create a new Workbook Dim workbook As New Workbook Dim worksheet As IWorksheet = workbook.Worksheets(0) worksheet.PageSetup.PrintGridlines = True worksheet.PageSetup.PrintHeadings = True '"A1" is ordinary wrapped text. worksheet.Range!A1.WrapText = True worksheet.Range!A1.Value = "Document Solutions for Excel" worksheet.Range!A1.RowHeight = 42 worksheet.Range!A1.ColumnWidth = 9 'The wrapped text "A2" will be sheink to fit. 'worksheet.Range["A2"].Interior.Color = Color.LightGreen; worksheet.Range!A2.WrapText = True worksheet.Range!A2.ShrinkToFit = True worksheet.Range!A2.Value = "Document Solutions for Excel" worksheet.Range!A2.RowHeight = 32 'You must create a pdfSaveOptions object before using ShrinkToFitSettings. Dim pdfSaveOptions As New PdfSaveOptions 'Shrink the wrapped text within the cell with existing row height/column width, while exporting to PDF. pdfSaveOptions.ShrinkToFitSettings.CanShrinkToFitWrappedText = True 'Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions) 'Set minimum font size with which the text should shrink. 'pdfSaveOptions.ShrinkToFitSettings.MinimumFont = 10; 'If after setting the minimum font size, the text is very long not fully visible, the ellipsis string to show for long text. 'pdfSaveOptions.ShrinkToFitSettings.Ellipsis = "~"; 'Save the workbook into pdf file. workbook.Save(outputStream, pdfSaveOptions)