Hi all,
Recently I got one requirement, to prepare word & excel file through automated batch process. I am new to working with word using C#
Here is my steps & problem... Please guide me.
1) I have word template file (.dot) file
2) I have couple of predefine bookmarks in this template (.dot) file
3) From c# I am opening this template and replacing bookmarks value with actual value
For example following are my bookmark in (.dot) file (template file)
A_B_C_D P_Q_R
C_Y_T_Z R_V_N
R_M_W_Q J_E_K
now based on condition i am putting different value for these
bookmark. Also I am checking if the
actual value for "P_Q_R" bookmark is null I am checking actual value for "R_V_N" bookmark
and replacing actual value of "A_B_C_D" with "C_Y_T_Z" & "P_Q_R" with "R_V_N" respectively
Now based on my left side bookmark actual text length the right side alignment not coming properly.
for example
Hello h r u 100.55
fine 54.12
C# programming 102.85
something here if too long 211.53
I dont want to use table
Highly appreciate your help & any suggestion; I am really stuck with
this problem,
thanks a lot
pbr
prashant rathodPosted Jul 20, 2008, 1:10 AM
Thanks for your reply.
But we can't resolve this problem using Hashtable & dictionary object,
The problem with formatting while replacing bookmark value. Alignment is not proper.
I will try to explain the problem...
suppose following are bookmarks in 'example.dot' file
A_B_C_D (bookmark1) R_S_T (bookmark2)
E_F_G_H (bookmark3) P_Q_R (bookmark4)
I_J_K_L (bookmark5) N_O_P (bookmark6)
...........
...........
here is our Hashtable Key/Value
Key Value
102.50 You used service A
85.29 Service is not available is different charge
6.99 Installation charge
0.99 Let fee
Now i am going to replace Left side bookmarks text (1,3,5) with above Hashtable values and right side bookmarks text (2,4,6) with above Hashtable keys.
left side bookmarks text (1,3,5) comes proper way, but right side bookmarks text (2,4,6) alignment not coming properly. sometime its little left & some time little right, & this is because of left side bookmarks text (1,3,5) length.
Can we fixed the bookmarks position in .dot file?
Thnak you,
Prashant
Bechir BejaouiPosted Jul 19, 2008, 8:20 AM
foreach (DictionaryEntry de in yourHashTable)
{ Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); }