Convert Text To Table

Hi,

I am have a requirment where i need to Migrate VB6 application to DOTNET.

In Vb6 application I have a method which creates a word document and puts the text(tabs between words) in word document and then select the text from starting from a particular line till the end of the word document and places a table for the selected text.

Example

Text1 Text2 Text3 Text4 Text5 Text6 Text7 Text8 Text9 Text10 Text11 Text12 Text13

Text14 Text15 Text16 Text17 Text18 Text19 Text20 Text21 Text22 Text23 Text24 Text25 Text26

It will have 13 columns like structure with tab space between each and rows depends on data.So this text should be placed into the table

Note : The text is run time genrated first the complete text will be generated into the word document with a tab space and then the table should be placed to the select text.

in Vb6 this is achived by

objWord.StartOfDocument -> Move to start of document
objWord.LineDown 3 -> go to line 4
objWord.EndOfDocument 1 -> select from line 4 to entire document

'Table generation
objWord.CharLeft 1, 1 -> move character left
objWord.TextToTable 1, 13 -> put the table from the complete document from line 4 for 13 columns
objWord.FormatBordersAndShading 3, 0, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, "0 pt", 0, 0, 0, "0", -1 -> format applied for table
objWord.StartOfDocument -> Move to start of document.

I need to achive the above code functionality in C#.Net using Aspose.

Thanks & Regards,

Ujwal.

Hi Ujwal,


Thanks for your inquiry. I think, you can achieve what you need after using the following code snippet:

ArrayList rows = new
ArrayList();
rows.Add(“Text1\tText2\tText3\tText4\tText5\tText6\tText7\tText8\tText9\tText10\tText11\tText12\tText13”);
rows.Add(“Text14\tText15\tText16\tText17\tText18\tText19\tText20\tText21\tText22\tText23\tText24\tText25\tText26”);

DocumentBuilder builder = new DocumentBuilder();
builder.PageSetup.Orientation = Orientation.Landscape;

builder.StartTable();
foreach (string row in rows)
{
string[] splits = row.Split(new
char[] { ControlChar.TabChar
});
foreach (string str in splits)
{
builder.InsertCell();
builder.Write(str);
}

builder.EndRow();
}

builder.EndTable();

builder.Document.Save(@“C:\temp\out.docx”);

I hope, this will help.

Best Regards,

Hi Awais Hafeez,

ThankYou for the reply.

Can you please let me know

How do I go to a particular line and Particular Position in a line of Word Document

like objWord.LineDown 3 and objWord.CharLeft

Regards,

Ujwal.

hi Ujwal,


Thanks for your request.

Please note that MS Word documents are flow documents and do not contain any information about its layout into lines and pages. So, unfortunately, there is no way to move to a specific line of text using Aspose.Words. Maybe, there is another way to achieve what you need. Could you please attach your document here for testing and tell me what content do you need to reach at?

Moreover, I would suggest you please read the following article on Moving the Cursor:
http://www.aspose.com/docs/display/wordsnet/Moving+the+Cursor

I hope, this will help.

Best Regards,