Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this code I tried is printing me the evaluation warning sheet witch is always activate in any excel file when we try to open it using spire.xls

I tried to remove this unwanted sheet or hide it to print the sheet I want ,but while I'm using Spire.xls it steel shows.

I tried to activate my [0]sheet but the second steel shows !

PS:my excel file have only one sheet + the evaluation warning sheet .

how can I fixe my code to print me my excel file sheet ignoring the spire warning sheet or specify the sheet number !

Thank you for any help!

What I have tried:

private void Print_Click(object sender, RoutedEventArgs e)
{
    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
    {
        FileName = @"Path\To\Your\excel_file.xls",
        Verb = "Print"
    });
}
Posted
Updated 28-Nov-17 0:46am

1 solution

private void Print_Click(object sender, RoutedEventArgs e)
{
 
Excel.Application APP = new Microsoft.Office.Interop.Excel.Application();
          Microsoft.Office.Interop.Excel.Workbook wb = APP.Workbooks.Open(
     my File path",
     Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
     Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
     Type.Missing, Type.Missing, Type.Missing, Type.Missing);
 
          // Get the first worksheet.
          // (Excel uses base 1 indexing, not base 0.)
   Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)wb.Worksheets[1];
 
    ws.PrintOut(
              Type.Missing, Type.Missing, Type.Missing, Type.Missing,
              Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900