We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to print a spreadsheet

Hi,

How can I print a spreadsheet in Windows UWP?

Best
Christian


5 Replies

AA Arulraj A Syncfusion Team February 5, 2019 01:03 PM UTC

Hi Christian, 

Thank you for requesting this feature. This feature is already existing in our database and here’s the link to the feature request page 

If the definition of this feature corresponds to your requirement, please vote and comment. We will prioritize the features every release based on the demands. 

Regards,  
Arulraj A 



CH Christian February 6, 2019 11:25 AM UTC

Is there a recommendation on how to go about printing Excel until the new feature is available?


MG Mohanraj Gunasekaran Syncfusion Team February 7, 2019 01:46 PM UTC

Hi Christian, 
 
Thanks for your update. 
 
As per our previous update, currently there is no in-built support to print the SfSpreadsheet. But, you can achieve this by exporting the SfSpreadsheet to pdf using PdfPage and PdfGrid then load that pdf file in PdfViewrCotrol to print the SfSpreadsheet those are available in “Syncfusion.PdfViewer.UWP.dll”. Please refer the following code example,  
  
Code example  
Xaml  
xmlns:pdfviewer="using:Syncfusion.Windows.PdfViewer"  
  
<pdfviewer:SfPdfViewerControl x:Name="pdfviewer"/>  
 
C# 
//Create a new PDF document. 
 
PdfDocument pdfDocument = new PdfDocument(); 
StorageFile storageFile = null; 
 
foreach (var sheet in this.spreadsheet.Workbook.Worksheets) 
{ 
    //Create the page 
    PdfPage pdfPage = pdfDocument.Pages.Add(); 
 
    //Create the parent grid 
 
    PdfGrid parentPdfGrid = new PdfGrid(); 
 
    //Add the rows 
    for (int i = 0; i < this.spreadsheet.ActiveSheet.UsedRange.Row; i++) 
    { 
        PdfGridRow row1 = parentPdfGrid.Rows.Add(); 
        row1.Height = 50; 
        parentPdfGrid.Columns.Add(this.spreadsheet.ActiveSheet.UsedRange.Column); 
        for (int j = 0; j < this.spreadsheet.ActiveSheet.UsedRange.Column; j++) 
        { 
            var style = this.spreadsheet.ActiveSheet.UsedRange[i, j]; 
            PdfGridCell pdfGridCell = parentPdfGrid.Rows[i].Cells[j]; 
            pdfGridCell.Value = style.Value; 
 
        } 
    } 
 
    //Draw the PdfGrid. 
    parentPdfGrid.Draw(pdfPage, PointF.Empty); 
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; 
    storageFile = await local.CreateFileAsync("Sample.pdf", CreationCollisionOption.ReplaceExisting); 
    //Save the document. 
    await pdfDocument.SaveAsync(storageFile); 
} 
if (storageFile != null) 
{ 
    FileStream stream = File.OpenRead(storageFile.Path); 
    pdfViewer.Unload(); 
    pdfViewer.LoadDocument(stream); 
    //Print the pdf file.  
    pdfViewer.Print(); 
    pdfDocument.Dispose(); 
} 
 
 
Please get back us if you need any further assistance on this. 
 
Regards, 
Mohanraj G 



CH Christian February 11, 2019 12:41 PM UTC

Thank you.
I cannot get that demo to work. I changed the syncfusion references to nuget packages, I obviously we do not have the same folder structure.
The demo starts (very slow). Eventually I can see a grid with numbers, but the app is forzen.

Attachment: SpreadsheetDemo_4e508921.zip


SP Subburaj Pandian Veluchamy Syncfusion Team February 12, 2019 11:30 AM UTC

Hi Christian, 
  
Thank you for the update. 
  
By default, SfSpreadsheet control does not have the support to print the cells. So, we have tried to load the cell values in PdfGrid and load that PdfGrid in PdfDocument. Then, we have used the PdfViewer control used to load and print that pdfDocument. So, obviously those operations will take this much of time to print the SfSpreadsheet. This is our current support to print the SfSpreadsheet control. 
  
Please get back us, if you have any query on this. 
 
Regards,
Subburaj Pandian V  


Loader.
Live Chat Icon For mobile
Up arrow icon