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

Free Support Forum - aspose.com

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.

http://docs.aspose.com/display/wordsjava/How+to++Insert+a+Document+into+another+Document

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

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.

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

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.