"Paper Size" changes after adding trademark

Hi,

The “Paper Size” changes after adding trademark.(Version Aspose.Cells 8.2.0.1) Kindly check the pictures in the attachment.

The “Paper Size” should be “A4”, but it changes to “Letter”.(Page 3)

Here is the code:

// excel signature

@Override

protected void xxx(DecorateContext context) throws DecorateException {

logger .debug(“ExcelDecorator.doSignature”);

Workbook workbook = context.getContent(Workbook.class );

DecorateRequest request = context.getRequest();

StringBuilder signSb = new StringBuilder();

signSb.append(EdocTool.getInstance().encryptAES(request.getDocId())).append(“,”)

.append(EdocTool.getInstance().encryptAES(request.getDocVersion())).append(“,”)

.append(EdocTool.getInstance().encryptAES(request.getQrCode()));

CustomDocumentPropertyCollection cps = workbook.getCustomDocumentProperties();

//Record to encrypt the information to the property field

cps.add(DIGITAL_SIGN , signSb.toString());

}

protected void doSave(DecorateContext context) throws DecorateException {

logger .debug(“ExcelDecorator.doSave”);

String path = context.getRequest().getNewDocTempFullPath();

Workbook workbook = context.getContent(Workbook.class );

try {

File tarFile = new File(path);

(tarFile.getParentFile()).mkdirs();

workbook.save(path);

logger .debug(“save(path):” +path);

/

} catch (Exception e) {

throw new DecorateException(“save excel file error “, e);

}

}

// Add QR code

private void addQrCode(Worksheet sheet, byte [] picData, int position) {

if (picData != null ) {

PageSetup pageSetup = sheet.getPageSetup();

String footerStr = pageSetup.getFooter(position);

if (footerStr == null ) {

footerStr = “&G”;

} else {

footerStr = “&G\n” + footerStr;

}

pageSetup.setFooter(position, footerStr);// “&G”

pageSetup.setFooterPicture(position, picData);

}

}

// Add watermark

private void xxx(Worksheet sheet, byte [] vPicData, byte [] hPicData, int position) {

if (vPicData != null || hPicData != null ) {

PageSetup pageSetup = sheet.getPageSetup();

int orientation=pageSetup.getOrientation();

String footerStr = pageSetup.getFooter(position);

if (footerStr == null || “&G”.equals(footerStr)) {

footerStr = “&G”;

} else if (!footerStr.contains(”&G”)) {

footerStr = “&G\n” + footerStr;

}

pageSetup.setFooter(position, footerStr);// “&G”

if (orientation == 1) {

pageSetup.setFooterPicture(position, vPicData);

} else {

pageSetup.setFooterPicture(position, hPicData);

}

}

}

Thanks & Regards

余佳婧 (Sara Yu)

深圳市华软泰科科技有限公司
Shenzhen Chinasoft Information Technology Co., Ltd.

深圳市南山区高新区南区科技南十路深圳航天技术创新研究院D209
Rm.209, Shenzhen Academy of Aeroapace Technology Bldg., Kejinan 10th Rd.,South High-tech Zone,Nanshan Dist.,Shenzhen,China 518057

Skype: sara.yu1688
Tel: +86-755-26994896

Fax: +86-755-26996813
Mob:+86-18823209951

Email:yujq@chinasofttech.com

QQ: 444391387

Web: www.sz168.com.cn

Hi,

Thanks for your posting and using Aspose.Cells.

Please download and use the latest version: Aspose.Cells
for Java v8.2.0.4
it is working fine.

We have tested this issue with the following runnable sample code and did not find any issue. Please see the attached output Excel file generated by the code and screenshot showing the paper size which is still A4.

If your issue still occurs, then please provide us a runnable sample code replicating this issue with the latest version. We will look into it and help you asap.

Java


File img = new File(“D:/Documents and Settings/AHome/Desktop/sc.jpg”);


byte[] picData = new byte[(int)img.length()];


FileInputStream fin = new FileInputStream(img);

fin.read(picData, 0, picData.length);


int position = 0;


String filePath = “F:/Shak-Data-RW/Downloads/123.xlsx”;


Workbook workbook = new Workbook(filePath);


Worksheet sheet = workbook.getWorksheets().get(“xxx”);


PageSetup pageSetup = sheet.getPageSetup();


String footerStr = pageSetup.getFooter(position);


if (footerStr == null)

{


footerStr = “&G”;


}

else

{


footerStr = “&G\n” + footerStr;


}


pageSetup.setFooter(position, footerStr);// “&G”


pageSetup.setFooterPicture(position, picData);


workbook.save(filePath + “.out.xlsx”);

Thank you very much for your fast response and useful solution!


We met two new problem which require your help as well. Could you help us to confirm these two “rar” in the attachment? (Version:Aspose.cell 8.2.0.1 )

Best Regards
Sara

Hi Sara,

Thanks for your posting and using Aspose.Cells.

We were able to reproduce the exception with one of your file (i.e 0001.xls) but not with the other file (i.e 0003.xlsx).

Could you please post your sample code to let us know how to reproduce the exception with 0003.xlsx file?

However, we have found that your 0001.xls file is some what corrupted. Please see the screenshot that shows Excel warning on opening your file.

Anyway, we have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-41026 - This file’s format is not supported… exception on opening the source file.

We have tested this issue with the following sample code and also posted the exception for a reference.

Java

String filePath = “F:/Shak-Data-RW/Downloads/0001.xls”;


Workbook workbook = new Workbook(filePath);

Exception:
Exception in thread “main” com.aspose.cells.CellsException: This file’s format is not supported or you don’t specify a correct format.
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.(Unknown Source)

Hi,


We have evaluated your issue further. Well, “0001.xls” file format is actually Excel 95. Aspose.Cells does not
support it. Please open the file into MS Excel, click “Save as”,
you can see “Microsoft Excel 5.0/95 Workbook(.xls)” in the “Save as type”. Aspose.Cells supports the file format i.e…, Excel
97-2013 (BIFF8 or higher). Please re-save the file in MS Excel and use Aspose.Cells then it will work fine.


Thank you.

@chinasoft,

This is to inform you that we have supported Excel 95/5.0 (XLS files) - Support BIFF7 XLS files now. We will soon provide you the supported version after performing QA and incorporating other enhancements and fixes.

Keep in touch.

The issues you have found earlier (filed as CELLSJAVA-41026) have been fixed in Aspose.Cells for Java 19.1. You can also get the latest Aspose.Cells for Java version from Maven repos. with simple configurations. Please see the document for your reference: Installation|Documentation

This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi