Is it possible to tell how much of a given text can fit into a table cell? This example puts everything in the first cell, I need to split it in two without resizing the first cell or changing the font.
using System.IO;
using System.Reflection;
using Word = Microsoft.Office.Interop.Word;
class Program
{
static void Main()
{
string filename = "example.docx";
string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor";
var wordApp = new Word.Application { Visible = false };
string path = Path.Combine(Directory.GetCurrentDirectory(), filename);
var doc = wordApp.Documents.Open(path, ReadOnly: false, Visible: true);
doc.Activate();
var table = doc.Tables[1];
// todo: truncate text by the cell's size
table.Cell(1, 1).Range.Text = text;
string text2 = "";
// todo: put the remainder of the truncated text to text2
table.Cell(2, 1).Range.Text = text2;
doc.Save();
object missing = Missing.Value;
doc.Close(ref missing, ref missing, ref missing);
wordApp.Quit(ref missing, ref missing, ref missing);
}
}