Hello,
We are currently using Apsose Cells 4.4.0.0 version in our applications. Now wanted to use the same in a .NET bases web service. The web service recieves few files and these files should be printed using the required printer. To perform this task we are currently using EXCEL COM objects and we want to replace the COM object with Aspose.Cells however we could not find any provision to print a xls file with the version we have. Please help us in this regard.
For our printing tasks all the sheets available should be considered. The code we are currently using is as follows:
//Create a new excel object
Excel.Application MSExcel = new Excel.Application();
//Declare variable of excel workbook type
Excel._Workbook XLBook;
//Set the alerts to false, this would not display any alerts from excel
MSExcel.DisplayAlerts = false;
// Open the excel file
XLBook = MSExcel.Workbooks.Open(strPath, 0, true, 5, "", "",
true, 2, "", false, false, false, false, 1, false);
//Select all the excel sheets in the excel workbook
XLBook.Sheets.Select(null);
//Activate the entire workbook
XLBook.Activate();
//Declare variable of type excel worksheet
Excel._Worksheet wSheet;
//Assign all the selected sheets to the excel sheet variable
wSheet = (Excel._Worksheet) XLBook.ActiveSheet;
//The below lines of code are used to make sure all the contents of the excel file are displayed in a single page when converted to PDF
wSheet.PageSetup.PrintTitleRows = "";
wSheet.PageSetup.PrintTitleColumns = "";
wSheet.PageSetup.PrintArea = "";
wSheet.PageSetup.LeftHeader = "";
wSheet.PageSetup.CenterHeader = "";
wSheet.PageSetup.RightHeader = "";
wSheet.PageSetup.LeftFooter = "";
wSheet.PageSetup.CenterFooter = "";
wSheet.PageSetup.RightFooter = "";
wSheet.PageSetup.PrintHeadings = false;
wSheet.PageSetup.PrintGridlines = false;
wSheet.PageSetup.PrintComments = Excel.XlPrintLocation.xlPrintNoComments;
wSheet.PageSetup.CenterHorizontally = false;
wSheet.PageSetup.CenterVertically = false;
wSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait;
wSheet.PageSetup.Draft = false;
wSheet.PageSetup.PaperSize = Excel.XlPaperSize.xlPaperLetter;
wSheet.PageSetup.Zoom = false;
wSheet.PageSetup.FitToPagesWide = 1;
wSheet.PageSetup.FitToPagesTall = false;
//Print the excel file opened
XLBook.PrintOut(1, 9999, 1, false, ConfigurationSettings.AppSettings["PrinterName"].ToString(), true, 0, "");
//Save the workbook
XLBook.Saved = true;
//Close the excel workbook
XLBook.Close(false, "", false);
//Clean up all the objects created
MSExcel.Quit();
MSExcel = null;
XLBook = null;