We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

"Paper Size" changes after adding trademark

Hi,


The “Paper Size” changes after adding trademark.(Version Aspose.cell 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<o:p></o:p>

protected void xxx(DecorateContext context) throws DecorateException {<o:p></o:p>

logger.debug(“ExcelDecorator.doSignature”);<o:p></o:p>

Workbook workbook = context.getContent(Workbook.class);<o:p></o:p>

<o:p></o:p>

DecorateRequest request = context.getRequest();<o:p></o:p>

StringBuilder signSb = new StringBuilder();<o:p></o:p>

signSb.append(EdocTool.getInstance().encryptAES(request.getDocId())).append(",")<o:p></o:p>

.append(EdocTool.getInstance().encryptAES(request.getDocVersion())).append(",")<o:p></o:p>

.append(EdocTool.getInstance().encryptAES(request.getQrCode()));<o:p></o:p>

CustomDocumentPropertyCollection cps = workbook.getCustomDocumentProperties();


//Record to encrypt the information to the property field

cps.add(DIGITAL_SIGN, signSb.toString());<o:p></o:p>

}<o:p></o:p>

protected void doSave(DecorateContext context) throws DecorateException {<o:p></o:p>

logger.debug(“ExcelDecorator.doSave”);<o:p></o:p>

String path = context.getRequest().getNewDocTempFullPath();<o:p></o:p>

Workbook workbook = context.getContent(Workbook.class);<o:p></o:p>

<o:p></o:p>

try {<o:p></o:p>

<o:p></o:p>

File tarFile = new File(path);<o:p></o:p>

(tarFile.getParentFile()).mkdirs();<o:p></o:p>

workbook.save(path);<o:p></o:p>

logger.debug(“save(path):” +path); <o:p></o:p>

/ <o:p></o:p>

} catch (Exception e) {<o:p></o:p>

throw new DecorateException(“save excel file error “, e);<o:p></o:p>

}<o:p></o:p>

<o:p></o:p>

}


// Add QR code

private void addQrCode(Worksheet sheet, byte[] picData, int position) {<o:p></o:p>

if (picData != null) {<o:p></o:p>

PageSetup pageSetup = sheet.getPageSetup();<o:p></o:p>

String footerStr = pageSetup.getFooter(position);<o:p></o:p>

if (footerStr == null) {<o:p></o:p>

footerStr = “&G”;<o:p></o:p>

} else {<o:p></o:p>

footerStr = “&G\n” + footerStr;<o:p></o:p>

}<o:p></o:p>

pageSetup.setFooter(position, footerStr);// “&G”<o:p></o:p>

pageSetup.setFooterPicture(position, picData);<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

// Add watermark

private void xxx(Worksheet sheet, byte[] vPicData, byte[] hPicData, intposition) {<o:p></o:p>

if (vPicData != null || hPicData != null) {<o:p></o:p>

PageSetup pageSetup = sheet.getPageSetup();<o:p></o:p>

int orientation=pageSetup.getOrientation();<o:p></o:p>

String footerStr = pageSetup.getFooter(position);<o:p></o:p>

if (footerStr == null || “&G”.equals(footerStr)) {<o:p></o:p>

footerStr = “&G”;<o:p></o:p>

} else if (!footerStr.contains(”&G”)) {<o:p></o:p>

footerStr = “&G\n” + footerStr;<o:p></o:p>

}<o:p></o:p>

pageSetup.setFooter(position, footerStr);// “&G”<o:p></o:p>

if (orientation == 1) {<o:p></o:p>

pageSetup.setFooterPicture(position, vPicData);<o:p></o:p>

} else {<o:p></o:p>

pageSetup.setFooterPicture(position, hPicData);<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

}<o:p></o:p>

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: https://docs.aspose.com/display/cellsjava/Installation

This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi