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

Free Support Forum - aspose.com

About the using of aspose .word for java

Hi,
I have two problems needed your help
1. I want to change the orientation of the whole table ,not only the text of cell. I want to extend the table which binded data in my template document horizontally .
2. There's a table In my template document which binded the datasource. And I want to merge the cell in the first column after running the application.
By the way ,Why I can't insert my attachement and reply for my lasted messages.

Thank you!

Best Regards,

Candy

Hi Candy,

Thanks for your inquiry.

Could you please attach your template here demostrating what you would like to achieve with your tables? From the sounds of things, you want to transpose the rows of your table after merging?

I believe you mean you want to merge the cells of a table after data has been merged into them. This is possible yes, although it takes a little extra work. I have actually made some sample code for this for another customer. You can find it here. If you have any troubles translating the code, please feel free to ask for help.

Could you please explain the problem you were having with attaching your files? What was the error message that popped up.

Thanks,

Hello,

I can't insert my attachment.Following is the error message:

消息: 缺少对象
行: 1
字符: 1
代码: 0
URI: http://www.aspose.com/community/forums/uploadattachment.aspx?SectionID=75


消息: 'dp' 未定义
行: 216
字符: 1
代码: 0
URI: http://www.aspose.com/community/forums/uploadattachment.aspx?SectionID=75

Do you have a email which I can send my attachment to you?

And I have another problems needed your help. There are a table with many columns in my template document and it can't show in one page. I want to split these colums into two part and show them in two pages. How I can do it ?

Hello,

The attachment is my template and the result docment .

The method about the cellMerge which you provided to me can use in the Java bulider?I cann't find the IFileMergingCallback Interface ?

Thank you!

Best Regards,

Candy

Hi Candy,

Thanks for posting your template here.

Did the attachment issue fix itself or did you need to do something? Can you share what happened? If you ever need to contact any Aspose staff member you can click the Contact button above any of their posts and choose commication using e-mail or PM.

I have taken a look at your template, I believe the simpliest way to achieve what you are looking for, is to have two tables, one with the headings and one with the data to be merged (as rows like normal). Then after merging transpose the "columns" to rows and append them to the first table with the headings.

I have created some simple code which does this. I have also attached the template I used here.

doc.getMailMerge().executeWithRegions(employees);

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

// First table with headings

Table mainTable = (Table)doc.getChild(NodeType.TABLE, 0, true);

// Data merged column-wise

Table mergeTable = (Table)doc.getChild(NodeType.TABLE, 1, true);

// Iterate through all rows in the merged table.

// We want to move the first cell of each row (first column) to the end of the first row of the main table

// We then want to move the second cell of each row (second column) to the end of the second row of the main table.

for(Node node : mergeTable.getRows().toArray())

{

Row row = (Row)node;

Cell firstCell = row.getFirstCell();

mainTable.getFirstRow().getCells().add(firstCell);

Cell secondCell = row.getFirstCell();

mainTable.getRows().get(1).getCells().add(secondCell);

// Set the width of each cell in the bottom row to be the same at the top so they are not off from each other.

secondCell.getCellFormat().setWidth(firstCell.getCellFormat().getWidth());

}

Regarding the merging of the actual table cells, I was unable to see any merging in your expected output. Could you provide an example and I will take a closer look and provide you with some feedback.

Regarding spliting columns into different pages, I don't quite understand your request. How do you want to split columns onto different pages? If you provide some further information I can give you a few suggestions.

Thanks,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Currently API of Java and .NET versions of Aspose.Words is a little different. In Aspose.Words for Java MergeFieldEventHandler is an analog of IFileMergingCallback:

http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/mergefieldeventhandler.html

If I understand your requirements correctly, you need to grow the table horizontally and vertically, i.e. if your data source contains 10 records as a result you should get table with 4 rows, where the last row contain only one data column. Is that correct? If so, I think, you should redesign your template and use regions along with NEXT fields. Please let me know if this is what you need and if you need an example.

Best regards.

Hello,

I use your method to merge the cells of a table after data has been merged into them,but it doesn't works well. The attchement is my codes and templete document. Is there anything error with my codes? Thank you!

Best Regards,

Candy

Hi Candy,

My apologises, I forgot to attach the template with my previous post.

This is the code that works with this template. If this is not applicable to what your doing you may want to try what Alexey suggested and see if that works better.

If you have any troubles, please feel free to ask.

Thanks,