Page Margins not set properly while importing xls2Doc with Latest Jar

hi,

We have been using the Aspose from quite a long time. I have updated to the latest release of aspose cells java recently. from that time we are facing formatting issues with the xls conversion into word. tables in xls are going out of borders in the word when imported. here I am attaching my files(input xls, output word, src java files) . please let me know Where I am going wrong.

Regards
Jeevan.

Hi,

I am afraid, I may not help you much in this regard. As you are using a custom converter probably created/originated by Aspose.Words team, so you should contact to them for your issues, may be they could help you.

For Aspose.Cells for Java product, I can only help you if you find any issues in creating or manipulating/managing Excel’s XLS/XLSX files. For doc/docx files issues, please contact the author of the converter.

Also as a side note, you may try our latest fix if it make any difference:Aspose-cells-7.1.1.4-java

Thank you.

Thank you… Can you please move this to Aspose words forum for Java.

Hi,

As per your request, we have moved your thread in Aspose.Words forum. Aspose.Words team will help you asap.

Hi,

Thanks for the additional information and sorry for the delayed response. We’re working on your query and will get back to you soon.

We’re sorry for the inconvenience and appreciate your cooperation.

hi,
output seems to be very good. but here I am not getting the same kind of out put. we are using jdk5. PPP.doc is nothing but the out put file. before inserting doc at the bookmark, we are deleting the content and inserting. so input and out put are same.

Regards
Jeevan.

Hi Jeevan,

Thanks for sharing the information. I used JDK 1.6 with shared code. I will update you after testing the scenario with JDK 1.5.

Hi Jeevan,

I have tested the scenario with JDK 1.5 and have not found any issue. Please use the following code snippet to generate document. You can find the insertDocument function from following documentation link.

https://docs.aspose.com/words/java/insert-and-append-documents/

ConverterXls2Doc converterXls2Doc = new ConverterXls2Doc("D:\\LL.xls", true, "Arial", "10");
converterXls2Doc.convert(false);
Document convertedWordDoc = converterXls2Doc.getDocument();
Document sectionDocument = new Document("D:\\PPP.doc");
Bookmark bookmark = sectionDocument.getRange().getBookmarks().get("Appendix1_MAStatus");
insertDocument(bookmark.getBookmarkEnd().getParentNode(), convertedWordDoc);
sectionDocument.save("D:\\Out.doc");

hi,

your output doc looks very impressive but I am not able to get the kind of document generated from my side with your code. can you please confirm that you did not change any thing in ConverterXls2Doc.java
Something is missing here or with you. because for the same jars and code…
we are getting two different kinds of outputs.

Regards
Jeevan

Hi Jeevan,

Please find the code used by me in attachment.

Hi Tahir,
Thanks for all the work you are putting in for me. but the code u sent also did not work for me. kindly find the attached excel and word which I am using.

Regards
Jeevan

Hi Jeevan,

I have done some changed in insertDocument method. Please see code under comments (//New Changes for tables) in insertDocument method. I have attached the code and output document with this post.

Hope this helps you. Let me know, If you have any more queries.

HI Tahir,
I have seen the output. but it is not the desired one, as we have moved the table to the left from the margins. table should fit with in the margins. especially left margin.

Regards
Jeevan

Hi Jeevan,

Please accept my apology for late response. I have modified your template file, I have set the left and right margin to 1.99 cm same as converted document from XLS. Please find the output and modified template file in attachment.

Hi Tahir,
Firstly let me thank you for all the work you are putting in and taking my questions.
In our application we are not supposed to change the margins and the table should be actually fit in the specified margins. it can go out of margins on the right side , but not on the left margin.

can we fit in any table to fit in the specified marginal width. hope it clears.

Regards
Jeevan

Hi Jeevan,

Further to my last reply. You can set the margin by code. Please see below.

ConverterXls2Doc converterXls2Doc = new ConverterXls2Doc("D:\\Data\\Customers\\LL.xls", true, "Arial", "10");
converterXls2Doc.convert(false);
Document convertedWordDoc = converterXls2Doc.getDocument();
Document sectionDocument = new Document("D:\\Data\\Customers\\PPP.doc");
DocumentBuilder builder = new DocumentBuilder(sectionDocument);
// 56.4 point = 1.99 cm
PageSetup ps = builder.getPageSetup();
ps.setLeftMargin(56.4);
ps.setRightMargin(56.4);
// DocumentBuilder builder = new DocumentBuilder(sectionDocument);
// DocumentBuilder builder2 = new DocumentBuilder(convertedWordDoc);
// PageSetup ps = builder.getPageSetup();
// ps.setLeftMargin(builder2.getPageSetup().getLeftMargin());
// ps.setRightMargin(builder2.getPageSetup().getRightMargin());
Bookmark bookmark = sectionDocument.getRange().getBookmarks().get("Appendix1_MAStatus");
insertDocument(bookmark.getBookmarkEnd().getParentNode(), convertedWordDoc);
sectionDocument.save("D:\\Data\\Customers\\Out.doc");

Hi Jeevan,

It would be great, If you share how you create the template file. I have created a sample template same as yours and it works fine. Please find it in attachment and use it. Let me know, If it works at your side.