I’m evaluating Aspose.Words for our application. It has to do the following:
We have documents, in wich the user can place tags, like <%client%>
or <%address%>
; Those tags are common text in the document, we can’t use mailmerge. Then i have to read those tags and replace by some values that are registered in the database. I accomplished this very easily with aspose (it would be a lot easier if i used mailmerge, but i could get it to work, reading the tags like this:
public List GetAllTags(Regex padraoTag)
{
if (doc == null)
throw new Exception("Documento nπo carregado.");
List tagList = new List();
String txt = doc.GetText();
MatchCollection mc = padraoTag.Matches(txt);
foreach(Match m in mc)
{
tagList.Add(m.Value);
}
return tagList;
}
and replacing them like this:
public void ReplaceTag(String Tag, String Valor)
{
doc.Range.Replace(new Regex(Tag), Valor);
}
Now i have to do the following: some values will be registered in the database with pipes, like “value1|value2|value3”. If i find a value like this, i have to split it and replace the associated tag, inserting a line break after each value like:
value1
value2
value3
That also was easy to do using ReplaceEvaluator. The problem i’m having is if the tag is inside of a table. The user wants the values to be inserted one at a row… I could make it work for one value, but it doesn’t work right if the table has 2 tags in the same row, like:
row1:
cell1 content: <%tag1%>
cell2 content: <%tag2%>
and then <%tag1%>
would be associated to “val1|val2|val3”, each value into a new row, and <%tag2%>
with “val4|val5|val6”, each value into a new row also.
Please, tell me if there is a way to do it. Also if there is an easier way to do everything i accomplished so far… The documentation is very good, but i’m having a real hard time with this table issue…
I’m sending the code from the last time i tried attached.
Thanks,
Samuel
This message was posted using Page2Forum (attachment) from Aspose.Words.Tables - Aspose.Words for .NET and Java