Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Aug 02, 2023 9:53 pm

Hello,

I'm evaluation Spire.Doc for a project I'm working on. I am using FreeSpire.Doc v9.9.7. I would like to be able to create a table whereby each cell can have a different text rotation. Every time I apply TextDirection.RightToLeftRotated to *any* cell in the table, all cells take on that rotation even if I've specified a different rotation for another cell. Below is a sample program that exhibits the problem.

Thanks for any guidance you can give.

Document document = new Document();
Section sec = document.AddSection();
Table table = sec.AddTable();
table.ResetCells(2, 2);
TableCell cell = table.Rows[0].Cells[0];
TableCell cell2 = table.Rows[1].Cells[1];
table.Rows[0].Height = 100;
table.Rows[1].Height = 100;
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
cell2.CellFormat.VerticalAlignment = VerticalAlignment.Top;
cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated;
cell2.CellFormat.TextDirection = TextDirection.RightToLeft;
cell.AddParagraph().AppendText("01");
cell2.AddParagraph().AppendText("*23L01*");

string fileName = @"y:\Documents\Temp\example.docx";
System.IO.File.Delete(fileName);
document.SaveToFile(fileName, FileFormat.Docx);

m00003643
 
Posts: 3
Joined: Wed Aug 02, 2023 9:41 pm

Thu Aug 03, 2023 6:15 am

Hi,

Thank you for reaching out to us regarding the issue with setting text direction in our DOC product. We would like to clarify that our DOC product follows the standards set by Microsoft Word. In MS Word, it is not supported to have different text directions within a single section.

To further investigate this matter, we recommend testing the text direction functionality in Microsoft Word itself. You will likely encounter the same limitation when attempting to set different text directions within a section.

We want to assure you that this behavior is not specific to our product and is inherent to the design of Microsoft Word. If you have any further questions or concerns, please feel free to let us know, and we will be happy to assist you.

Thank you for your understanding.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Thu Aug 03, 2023 3:04 pm

Thanks for your reply. I am able to do what I want directly in Microsoft Word version 16.56. See attached image. This is a table with one row and two columns within on section.

Regards

m00003643
 
Posts: 3
Joined: Wed Aug 02, 2023 9:41 pm

Fri Aug 04, 2023 3:49 am

Hi,

I am writing in response to your feedback regarding the TextDirection issue in our Doc product. Firstly, I would like to apologize for any confusion caused by my previous statement. Please accept my sincere apologies.

The code you provided, cell.CellFormat.TextDirection = TextDirection.RightToLeftRotated; and cell2.CellFormat.TextDirection = TextDirection.RightToLeft;, actually sets the same text direction. Therefore, when you open the resulting document, the displayed text direction will be the same.

The "Rotated" suffix in the TextDirection enumeration is used to control whether non-East Asian fonts are rotated. It does not affect the overall text direction. In this case, if you wish to explore different text directions, I encourage you to try other available options and experiment with them.

Once again, I apologize for any confusion caused. If you have any further questions or need assistance with anything else, please feel free to reach out to us. We are here to help.

Thank you for your understanding.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Mon Aug 07, 2023 7:30 pm

I'm still unclear from your comments what I can expect Spire.doc to do or not do regarding rotated text. Is is possible for Spire.doc to create a Word Doc like the one I show in the attachment on my post dated 8/3/2023?

Regards.

m00003643
 
Posts: 3
Joined: Wed Aug 02, 2023 9:41 pm

Tue Aug 08, 2023 2:06 am

Hi,

Thanks for your feedback.
Please refer to the following code.
Code: Select all
Document document = new Document();
Section sec = document.AddSection();
Table table = sec.AddTable(true);
table.ResetCells(2, 2);
TableCell cell = table.Rows[0].Cells[0];
TableCell cell2 = table.Rows[0].Cells[1];
table.Rows[0].Height = 50;
table.Rows[1].Height = 50;
cell.CellFormat.VerticalAlignment = VerticalAlignment.Top;
cell.CellFormat.TextDirection = TextDirection.RightToLeft;
cell.AddParagraph().AppendText("hello");

cell2.CellFormat.VerticalAlignment = VerticalAlignment.Top;
cell2.CellFormat.TextDirection = TextDirection.TopToBottom;
cell2.AddParagraph().AppendText("world");

string fileName = "example.docx";
document.SaveToFile(fileName, FileFormat.Docx);

test.png

If the code does not meet your requirement or you have other questions, just feel free to contact us.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc