GrapeCity.Xaml.SpreadSheet.Data
BestFitColumns Property
Example 


Gets or sets whether column widths are adjusted to fit the longest text width for printing.
Syntax
'Declaration
 
<DefaultValueAttribute()>
Public Property BestFitColumns As Boolean
'Usage
 
Dim instance As PrintInfo
Dim value As Boolean
 
instance.BestFitColumns = value
 
value = instance.BestFitColumns
[DefaultValue()]
public bool BestFitColumns {get; set;}

Property Value

true if the column widths are adjusted to fit the longest text for printing; otherwise, false. The default value is false.
Example
This example uses the BestFitColumns property.
private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var filePicker = new Windows.Storage.Pickers.FileSavePicker();
                filePicker.FileTypeChoices.Add("PDF Files", new List<string>() { ".PDF" });
                filePicker.SuggestedFileName = "New SpreadSheet File";
                Windows.Storage.StorageFile storageFile = await filePicker.PickSaveFileAsync();
                if (storageFile != null)
                {
                    using (var stream = await storageFile.OpenStreamForWriteAsync())
                    {
                        var fileName = storageFile.FileType.ToUpperInvariant();
                        gcSpreadSheet1.Workbook.Name = "WorkBook";
                        gcSpreadSheet1.Sheets[0].Name = "Sheet 0";
                        GrapeCity.Xaml.SpreadSheet.Data.PrintInfo printtest;
                        printtest = gcSpreadSheet1.Sheets[0].PrintInfo;
                        printtest.FooterCenter = "This is Page &P";
                        printtest.HeaderCenter = "&A of &F";
                        printtest.HeaderLeft = "&KFFFF00Color &KFF0000RedColor";
                        printtest.BestFitColumns = true;
                        printtest.UseMax = true;
                        GrapeCity.Xaml.SpreadSheet.Data.PdfExportSettings test;
                        test = new GrapeCity.Xaml.SpreadSheet.Data.PdfExportSettings();
                        test.Title = "Print PDF";
                        test.Author = "GrapeCity, Inc.";
                        test.DisplayDocTitle = true;
                        test.FitWindow = true;
                        await gcSpreadSheet1.SavePdfAsync(stream, test, 0);
                    }
                }
            }
            catch (Exception ex)
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Error");
                dialog.ShowAsync();
            }          
        }
Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Try
            Dim filePicker As New Windows.Storage.Pickers.FileSavePicker()
            filePicker.FileTypeChoices.Add("PDF Files", New List(Of String)() From {".pdf"})
            filePicker.SuggestedFileName = "New SpreadSheet File"
            Dim storageFile As Windows.Storage.StorageFile = Await filePicker.PickSaveFileAsync()

            If storageFile IsNot Nothing Then
                Using stream = Await storageFile.OpenStreamForWriteAsync()
                    Dim fileName = storageFile.FileType.ToUpperInvariant()                    
                    gcSpreadSheet1.Workbook.Name = "WorkBook"
                    gcSpreadSheet1.Sheets(0).Name = "Sheet 0"
                    Dim printtest As GrapeCity.Xaml.SpreadSheet.Data.PrintInfo
                    printtest = gcSpreadSheet1.Sheets(0).PrintInfo
                    printtest.FooterCenter = "This is Page &P"
                    printtest.HeaderCenter = "&A of &F"
                    printtest.HeaderLeft = "&KFFFF00Color &KFF0000RedColor"
                    printtest.BestFitColumns = True
                    printtest.UseMax = True
                    Dim test As GrapeCity.Xaml.SpreadSheet.Data.PdfExportSettings
                    test = New GrapeCity.Xaml.SpreadSheet.Data.PdfExportSettings()
                    test.Title = "Print PDF"
                    test.Author = "GrapeCity, Inc."
                    test.DisplayDocTitle = True
                    test.FitWindow = True
                    await gcSpreadSheet1.SavePdfAsync(stream, test, 0)
                End Using
            End If
        Catch ex As Exception
            Dim dialog As Windows.UI.Popups.MessageDialog = New Windows.UI.Popups.MessageDialog(ex.Message, "Error")
            dialog.ShowAsync()
        End Try
    End Sub
Requirements

Target Platforms: Windows Server 2012, Windows RT

See Also

Reference

PrintInfo Class
PrintInfo Members

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options