Attached Backgroud image is not printing on the Printer

Hi ,

We are using the licesed Aspose software for adding the Back ground image into the Excel sheets.( Watermark). Everything is working fine and background image is not printing on the printer. Please sugget what would be the issue.

Code:
Workbook workbook = new Workbook();
workbook.open("c:\\text.xls");
Worksheets worksheets = workbook.getWorksheets();
int number = workbook.getWorksheets().size();

for (int i = 0; i < number; i++) {
Worksheet sheet = worksheets.getSheet(i);
File file = new File("c:\\release.JPG");
byte[] imageData = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(imageData);
sheet.setBackground(imageData);
}

workbook.save(filePath);

Regards,

Dheeraj

Hi Dheeraj,

I can see the problem and we are checking it in details. Once the actual reasons of this problem are identified, we will let you know.

Hi Dheeraj,

Well, Aspose.Cells works in the similar way as MS Excel. Actually it is a limitation put forth by MS Excel. If you could insert a worksheet background image manually in MS Excel (e.g In MS Excel e.g 2003, click menu option Format|Sheet|Background), then take its print preview (click menu option File|Print Preview), you can see that there is no background image (watermark). So, when you will print that sheet, the background image would not be printed. For your information, the background image (watermark) is only for display.

So, there is no issue regarding Aspose.Cells component.

Thank you.

Thanks for your quick response.

If the image is placed in the header (i.e. custom header,right section) of Excel, the image is displaying and printing.

is there any way we can implement it by using Aspose and print the background image ? Customer needs this functionality. How can we implement this? Please suggest.

Regards,

Dheeraj

Hi,

If the image is placed in the header (i.e. custom header,right section) of Excel, the image is displaying and printing.

Well, Aspose.Cells also allows to insert image headers / footers that would printed too. See the document for reference:

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-headers-and-footers.html


Well, if MS Excel allows this functionality, Aspose.Cells can do this otherwise not. If you could tell us how to print background images of excel sheets, we can check it for your need.


Thank you.

Hi Amjad,

Thanks for quick reply.

I have added the pictures into Header & Footer and now printing through thr Printer. How Can we remove/clear the added pictures into the Header & Footer. Please suggest.

The following code is using for adding the pictures into the Header & Footer.

Workbook workbook = new Workbook();
String logo_url = "D:\\Other\\ADC_Test\\PreReleased.JPG";
FileInputStream inFile = new FileInputStream(logo_url);
PageSetup pageSetup = workbook.getWorksheets().getSheet(0).getPageSetup();
pageSetup.setCenterHeader("&G");
pageSetup.addPicture(true, 1, inFile);
pageSetup.setRightHeader("&A");
workbook.save("D:\\Other\\ADC_Test\\test.xls");
inFile.close();

Regards,

Dheeraj

Hi,

pageSetup.ClearHeaderFooter() Method can be used in order to cleare the Header/ Footer.

Thanks,

Hi,

I'm usiung attached Aspose.cell jar file and doesn't find the below mentioned method. We are using the JDK1.4 supported Aspose jars.

pageSetup.ClearHeaderFooter()

Code:

Workbook workbook = new Workbook();
String logo_url = "D:\\Other\\ADC_Test\\Previous.JPG";
FileInputStream inFile = new FileInputStream(logo_url);
PageSetup pageSetup = workbook.getWorksheets().getSheet(0).getPageSetup();
pageSetup.ClearHeaderFooter(); // error doesn't find this method

Regards,

Dheeraj

Hi,

To remove pictures from header/footer of PageSetup, you can reset the header/footer scripts by methods like PageSetup.setLeftHeader(String)/setLeftFooter(String)/setCenter… To get the same result with ClearHeaderFooter() of .NET version, you can just input null for these methods.
e.g

pageSetup.setLeftHeader(null);

Hi Amjad,

I'm getting the null pointer exception when i set the null. I'm using the Java Aspose.cell. Please find the code below.

Workbook workbook = new Workbook();
String logo_url = "D:\\Other\\ADC_Test\\Previous.JPG";
FileInputStream inFile = new FileInputStream(logo_url);
PageSetup pageSetup = workbook.getWorksheets().getSheet(0).getPageSetup();
pageSetup.setCenterHeader(null);
// pageSetup.setLeftHeader(null);
pageSetup.setRightHeader(null);
workbook.save("D:\\Other\\ADC_Test\\test.xls");

Getting the following exception:

java.lang.NullPointerException
at com.aspose.cells.PageSetup.c(Unknown Source)
at com.aspose.cells.PageSetup.b(Unknown Source)
at com.aspose.cells.cY.o(Unknown Source)
at com.aspose.cells.cY.b(Unknown Source)
at com.aspose.cells.cY.w(Unknown Source)
at com.aspose.cells.cY.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)

Regards,

Dheeraj

Hi,

I have found the issue as you have mentioned. I have logged your issue into our issue tracking system with an id: CELLSJAVA-19034.

We will figure it out soon.

Thank you.

Hi,

For the issue of removing header/footer, we will improve
those methods to accept null too. As a workaround, at the moment, please use empty string “”
instead of null to clear headers/footers:

e.g
<o:p></o:p>

pageSetup.setCenterHeader("");

pageSetup.setLeftHeader("");

pageSetup.setRightHeader("");

<o:p></o:p>


Thank you.


Hi,

Please find the updated version of jar file in order to remove header/ footer.
The methods

setCenterHeader
setLeftHeader
setRightHeader

now accept null as argument.

Thanks,


The issues you have found earlier (filed as 19034) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.