Text file and template xls

Hello,

I need help for my project.

I have a text file and a template xls, I need to merge those 2 files!

Is it possible ? I can open the text file with :

workbook.Open("myfile.txt",FileformatType.TabDelimited);

but I need to use a template before is it possible ?

Thank you very much

Hi,


I think you may try to combine the two files, see the sample code below.
Sample code:
Workbook wb1 = new Workbook(@“e:\test2\myfile.txt”, new LoadOptions(LoadFormat.TabDelimited));
Workbook wb2 = new Workbook(“e:\test2\xlsfile.xls”);
wb2.Combine(wb1);
wb2.Save(“e:\test2\output.xlsx”);

Also, you may try to copy the worksheet b/w workbooks, see the topic:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/copying-and-moving-worksheets.html

Thank you.

Thank you for your solution,

but if I use the "combine" method, I obtain 2 worksheets but the data use the template.

I need to have only one wooksheet for result.

best regards

Hi.

In that case, I am afraid, you need to do it manually. For example, you may load the XLS file first, now load the second tab delimited file, export data to fill a data table or array from your tab delimited worksheet. Now, you can import data from data table/array to your XLS file' worksheet at your desired location.
See the topics on how to export and import data from/to worksheet:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/exporting-data-from-worksheets.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/importing-data-to-worksheets.html

Another way can be copying ranges:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/copy-range-data-with-style.html

An agricultural way can be, you may put value cell by cell using Cell.PutValue() method in the XLS file from your tab delimited worksheet obtaining in a loop using Cell.StringValue() etc.

Thank you.