We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Set alignment text in cell

Hi,
I use this code to insert text into a table cell, but the alignment remains justified.

textRange = table[fornituraHwSw.Count + 10].AddParagraph().AppendText("TOTALE");
                                table[fornituraHwSw.Count + 10].Paragraphs[0].ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;


11 Replies

DB Dilli Babu Nandha Gopal Syncfusion Team February 7, 2019 05:54 PM UTC

Hi Pio, 

Thank you for contacting Syncfusion support. 

Yes, the mentioned codes will change the horizontal alignment as center which can also be done as below. 
IWParagraph para = table[0, 0].AddParagraph(); 
para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; 

Please share us the complete code example used at your end along with the input document (if any) which will be helpful for us analyzing on the reported behavior. 

To know more about table formatting, please refer the following link. 

Regards, 
Dilli babu. 



PL Pio Luca Valvona replied to Pio Luca Valvona February 8, 2019 09:05 AM UTC

Hi,
I use this code to insert text into a table cell, but the alignment remains justified.

textRange = table[fornituraHwSw.Count + 10].AddParagraph().AppendText("TOTALE");
                                table[fornituraHwSw.Count + 10].Paragraphs[0].ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;


Hi Dilli,
thanks for response.

I noticed that the problem happens on the docx, because if after I convert the Word file to PDF I get the desired result. I use Libre Office and I am attaching both the file and the code used to populate the template.



Attachment: example_80dc8fba.zip


JK Jenefa Koilduraijebakumar Syncfusion Team February 11, 2019 11:39 AM UTC

Hi Pio,

We have created a input template Word document based on the given code snippet and output Word document to reproduce the reported issue at our end. But we are unable to reproduce the issue. We have attached the sample which we tried at our end for your reference and please find it from below link.

Sample link:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample_ASP.NET-908017430

Note:
Please refer the modified input document in “Data” folder and the code snippet in the “GenerateWord.aspx.cs” file inside the sample.

If you are still facing same issue means, then kindly modify the attached sample or modify the existing sample of yours
along with input and resultant document of your end and provide us to reproduce the issue at our end.


Regards,
Jenefa K




PL Pio Luca Valvona February 12, 2019 09:29 AM UTC

Hi Jenefa,
Thank you for your support. 
Unfortunately, I did not understand what the change, since the code, even if resized is equal to mine, much less I understand the change to the document.
You could explain verbatim the changes, because even using your code the problem does not resolve


DB Dilli Babu Nandha Gopal Syncfusion Team February 13, 2019 12:47 PM UTC

Hi Pio,   

We suspect that your requirement is to apply horizontal alignment for the paragraph “TOTALE”. Kindly add the highlighted codes in your application to achieve it. 
textRange = table[fornituraHwSw.Count + 1, 0].AddParagraph().AppendText("TOTALE"); 
textRange.OwnerParagraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center; 

If this solution doesn’t suit your requirement, then kindly share us the issue reproducing sample as requested in our last update so that we can analyze and provide a prompt solution at the earliest. 
  
Regards, 
Dilli babu. 



PL Pio Luca Valvona February 13, 2019 02:14 PM UTC

Hi Dilli,
thanks for response.

This solution is also not working.
Because using the suggested code, the paragraph alignment property, opening the document remains set to "justified".
Both by opening it with LibreOffice and with Word Online.




DB Dilli Babu Nandha Gopal Syncfusion Team February 13, 2019 03:31 PM UTC

Hi Pio, 

Kindly share us the issue reproducing sample as requested in our last update so that we can analyze and provide a prompt solution at the earliest.  

If you have any confidential data in your Word document, please replace with some dummy data and provide us the same or send to support@syncfusion.com by mentioning this forum. 
   
Regards, 
Dilli babu. 



PL Pio Luca Valvona February 13, 2019 04:00 PM UTC

Hi Dilli.
I am attaching the generated file with the code used and attached in a previous message.

Attachment: result_662ff8e3.zip


DB Dilli Babu Nandha Gopal Syncfusion Team February 14, 2019 12:26 PM UTC

Hi Pio, 
 
Thank you for your update. 
 
We have prepared a sample based on your requirement with dummy data which can be downloaded from the following link. 
 
Kindly modify the sample to reproduce the issue and share us the same. With the help of issue reproducing sample, we will proceed our investigation and provide you a prompt solution. 
 
Regards, 
Dilli babu. 
 
 



PL Pio Luca Valvona February 14, 2019 02:43 PM UTC

Hi Dilli,
thanks for response.

The solutions you've given me work. Analyzing the code in the example, I saw that the problem is caused by the location of this line of code:
table.ApplyHorizontalMerge(fornituraHwSw.Count + 101);

Moving it as in the code in the example, everything is working correctly.




DB Dilli Babu Nandha Gopal Syncfusion Team February 15, 2019 05:47 AM UTC

Hi Pio, 

We are glad to know that the reported issue has been resolved at your end. Please let us know if you need any further assistance. 

Regards, 
Dilli babu.  


Loader.
Live Chat Icon For mobile
Up arrow icon