Hi,
The above code works fine (printing the content in the excel sheet from the browser IE9) if I run my project locally (`http://localhost:2627/tech_23june2011/Default.aspx`) . But if I run remotely (`http://10.10.210.97/tech_23june2011/Default.aspx`) it throws error Aspose.cells.CellsException : Default printer is not set . Printer not found! For the error message please find the attached file.
The problem is : when the client click the print button , the serverside code cannot find the client’s default printername or path. I don’t know how to find client default printer name with path.
Can you please suggest a solution for this? Its very very urgent.
Code:
string filename = "c:\\one.xls"; // Saves to the file.
this.g.WebWorksheets.SaveToExcelFile(filename); // Sents the file to browser.
Response.ContentType = "application/vnd.ms-excel"; //Adds header. Response.AddHeader("content-disposition", "attachment; filename=book1.xls"); // Writes file content to the response stream.
Response.WriteFile(filename); // OK. //Response.End(); // string filename = "c:\\one.xls";
Workbook workbook = new Workbook();
workbook.Open(filename); //Page settings
workbook.Worksheets[0].PageSetup.FitToPagesWide = 1;
workbook.Worksheets[0].PageSetup.Orientation = PageOrientationType.Landscape; workbook.Worksheets[0].PageSetup.PaperSize = PaperSizeType.PaperA3; workbook.Worksheets[0].PageSetup.HeaderMargin = 0.7;
workbook.Worksheets[0].PageSetup.TopMargin = 1.1;
workbook.Worksheets[0].PageSetup.LeftMargin = 0.9; workbook.Worksheets[0].PageSetup.RightMargin = 0.9;
workbook.Worksheets[0].PageSetup.BottomMargin = 0.8;
workbook.Worksheets[0].PageSetup.FooterMargin = 0.5; //Add NT logo in the A1 cell of the excel sheet
workbook.Worksheets[0].Pictures.Add(0, 0, @"C:\inetpub\wwwroot\tech_23june2011\Images\NTLogo3.gif");
workbook.Save(filename);
PrinterSettings settings = new PrinterSettings();
workbook.Worksheets[0].SheetToPrinter(settings.PrinterName);
Many Thanks,
Assal.