Using the following code I get dotted grid lines rather that solid lines when I print from excel all is fine, please see attached spreadsheet and the code I am using below. sheet prints just not the same as with excel, please advise. thank you
Dim options As New Aspose.Cells.Rendering.ImageOrPrintOptions()
options.PrintingPage = PrintingPageType.Default
Dim wr As New SheetRender(Sheet, options)
wr.ToPrinter(My.Settings.DefaultPrinter)
Hi,
Amjad,
Are you saying that there is no way to make
gridlines appear to be solid like they are when
I actually print documents from Excel?
Hi,
Well, if you could open your template file into Ms Excel and take the print preview in it, you will see those dotted lines are there, so Aspose.Cells behaves correctly, see the screen shot taken in MS Excel for your reference:
http://prntscr.com/5qnrp2
To accomplish your task, you may easily set the solid lines borders around your range of data using Aspose.Cells APIs before printing the sheet, see the sample code for your reference:
e.g
Sample code:
//Instantiating a Workbook object
Workbook workbook = new Workbook(“e:\test2\GrossSkins+01-07-2015.xls”);
//Obtaining the reference of the first (default) worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[0];
//Set the range based on the data/contents.
int maxCol = workbook.Worksheets[0].Cells.MaxDataColumn;
int maxRow = workbook.Worksheets[0].Cells.MaxDataRow;
Range range=null;
if (maxCol > 0 && maxRow > 0)
{
range = worksheet.Cells.CreateRange(“A1”, CellsHelper.CellIndexToName(maxRow, maxCol));
}
//Apply borders to the range.
Style colstyle = workbook.Styles[workbook.Styles.Add()];
colstyle.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
colstyle.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
colstyle.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
colstyle.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
StyleFlag flag = new StyleFlag();
flag.Borders = true;
range.ApplyStyle(colstyle, flag);
//Saving the Excel file
workbook.Save(“e:\test2\out1.xlsx”);
Let us know if you still have any issue.
Thank you.
Amjad,
ok I tried that and it worked but printout does not look at good as printing directly from excel.
I also ran across another issue and am attaching the scanned result from using aspose and it is very fuzzy and the font does not look right and it does not fit on page as opposed to excel which it works fine in.
I will attach my scanned printout which I converted to a pdf and also send you the spreadsheet
Thanks,
Bob
Hi,
Thanks for the template files.
Well, it looks like the required fonts (used in the workbook) are not installed or missing on your system where you are printing or rendering Excel file to PDF file format. Please make sure that the relevant fonts used in your spreadsheet are properly installed/ set on your system. For your information, the features like rendering PDF, printing spreadsheets and Sheet to Image or other features do require the relevant fonts should be installed on your system.
Also, on a safer side, you should put all the relevant fonts into a folder and then specify the fonts directory path in your code using CellsHelper.FontDir attribute at the start of your program. Anyways, I did test your scenario/ case on my system (Windows 8, core i7, 8GB ram etc.) with Aspose.Cells for .NET v8.3.1.4, I just opened and converted your template Excel file to PDF using the following sample code, it works fine and the output PDF file is fine tuned, I have attached the output PDF file for your reference here.
e.g
Sample code:
…
//CellsHelper.FontDir = @“e:\test2\MyFontDir”;
Workbook workbook = new Workbook(strFilePath);
workbook.Save(outPDFFilePath)
Also, please try our latest version/fix: Aspose.Cells for .NET (Latest Version)
Thank you.
Amjad
sorry I was not clear in my previous post
the pdf file I sent you was generated by Aspose rendering from Excel code to an excel printout.
Dim wr As New SheetRender(Sheet, options)
I scanned that printout to a pdf file so I could send to you. Could you test the aspose rendering from the spreadsheet that I sent you and review the results
Thank you
Hi Bob,
Dim book = New Workbook(“D:/FinalResults+01-07-2015.xls”)
For Each sheet As Worksheet In book.Worksheets
If sheet.Cells.MaxDataColumn > 0 AndAlso sheet.Cells.MaxDataRow > 0 Then
sheet.AutoFitRows()
Dim render = New SheetRender(sheet, New ImageOrPrintOptions() With {.ImageFormat = ImageFormat.Jpeg})
render.ToImage(0, “D:/” & sheet.Name & “.jpg”)
'render.ToPrinter(PrinterName);
End If
Next sheet
Hello Amjad & Babar Raza,
Your support resolved all the issues I have had so far with rendering of excel sheets.
Without a doubt your Aspose team provides
support of your products second to none.
Your timely responses, patience, and thorough
messages are superb.
sincerely,
Bob
Hi Bob,