Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Jun 19, 2017 1:54 pm

Hi,

I am trying to create a PDF file by copying selected Range of Cells to another sheet. The PDF is getting created but I am getting a black background colour in PDF. Please can you let me know how to remove the background colour from the PDF?

private void button1_Click(object sender, EventArgs e)
{
string pdfFileName = "";
string excelFileName = "000000_ExcelReport_20170619_1120.xlsx";
pdfFileName = excelFileName.Replace("xlsx", "pdf").Replace("Excel", "PDF");
Workbook workbook = new Workbook();
workbook.LoadFromFile(excelFileName, ExcelVersion.Version2013);
workbook.Worksheets.Add("newsheet");
workbook.Worksheets[0].Range["A1:N32"].Copy(workbook.Worksheets[3].Range["A1:N32"]);
Worksheet worksheet = workbook.Worksheets[3];
CellRange range = worksheet.Range["A1:N32"];
PageSetup setup = worksheet.PageSetup;
setup.FitToPagesWide = 1;
setup.FitToPagesTall = 1;

worksheet.SaveToPdf(pdfFileName);
System.Diagnostics.Process.Start(pdfFileName);
}

Regards,
Sathya
Attachments
000000_ExcelReport_20170619_1120.zip
Files
(87.82 KiB) Downloaded 290 times

stimmaraju
 
Posts: 1
Joined: Mon Jun 19, 2017 1:38 pm

Tue Jun 20, 2017 2:26 am

Dear Sathya,

Thanks for your inquiry.
I have reproduced the issue and posted it to our Dev team. Once there is any progress, we will inform you immediately.
Sorry for inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Jul 26, 2017 6:52 am

Dear Sathya,

Here is a wrokaround to solve your issue, you could have a try.
Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("000000_ExcelReport_20170619_1120.xlsx");
            Worksheet sheet = workbook.Worksheets["Graph"];
            //set the PrintArea, then there will only be the PrintArea converted to PDF
            sheet.PageSetup.PrintArea = "A1:N32";
            sheet.PageSetup.Orientation = PageOrientationType.Landscape;
            string result = "result.pdf";
            workbook.SaveToFile(result, FileFormat.PDF);

Moreover, we will let you know when the bug is fixed.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Aug 11, 2017 6:46 am

Dear Sathya,

Thanks for waiting.
Now the background issue has been fixed, welcome to test Spire.XLS Pack Hotfix Version:7.12.69.
If there is any question, please let us know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS