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

Free Support Forum - aspose.com

Custom xml to word document

Hi,

I'm currently dealing with a problem for which I cannot finde a suitable solution.
Also I'm new to Aspose.Word so there might be an easy way to achieve what I'm trying to solve.

Following issue:
We've developed an application which is capable so solve complex calculations.
All calculations are encapsuled objects which are serialized to xml.
Now we want to change over to generate word documents from these xml files.

Only two things needed to be achieved:
1. Replace single field values.
2. Rewrite existing tables within our word template.

Our generated xml looks like this:

-
-
-
-
10000
-
3500
-
2
-
1.5
3
1
-
7000
-
0



is a table.
is a row.

is only a value which shall be replaced. In that case we think we could use a MERGEFIELD.

One of our problem is to be univocal within the word document.

For our example DustExplosionInternalPressure we would use a unique name for our MERGFIELD like:
TwoStepToriconicalFlatRoof_14015.DustExplosionInternalPressure.SIValue
So the content of SIValue could be perfectly matched.

We have to use this kind of naming because there could be other classes having the same DustExplosionInternalPressure.SIValue
but of course with a different value.

Actually our major problem is how we could solve tables.

One possible option could be that we use a syntax like yours:
Start of a table TableStart:TwoStepToriconicalFlatRoof_14015.AdditionalAttachments
Per row Row:TwoStepToriconicalFlatRoof_14015.AdditionalAttachments.AdditionalAttachment
Per cell Cell:TwoStepToriconicalFlatRoof_14015.AdditionalAttachments.AdditionalAttachment.DeadWeight.SIValue

A more elegant way would be if we could use a kind of a namespace.
So we could define a region in which all child elements are dependend of it's parent path.

E.g.:

{RegionStart:TwoStepToriconicalFlatRoof_14015}
{TableStart:AdditionalAttachments}
...
...
...
...
{TableEnd:AdditionalAttachments}
{ReginEnd:TwoStepToriconicalFlatRoof_14015}

I hope my explanation is sufficient to understand our problem.

Please tell me if there's a easier way and which classes of Aspose.Word you recommend for this job.

Kind regards

Hi Patrick,


Thanks for your inquiry. May be, you can simply load your XML data into DataSet and then perform a Mail Merge with Regions operation on your template Word document via Aspose.Words. I would suggest you please read the following articles:

http://docs.aspose.com/display/wordsnet/Mail+Merge+with+Regions+Explained
http://docs.aspose.com/display/wordsnet/How+to++Execute+Mail+Merge+with+Regions

Please let us know if you need more information, we are always glad to help you.

Best Regards,

Thanks alot.


Using TableStart: and ExecuteWithRegions() solved our issue.

Kind regards

Hi Patrick,


Thanks for your feedback. It is perfect that you managed to achieve what you were looking for. Please let us know any time you have any further queries.

Best Regards,