We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to get Excel data to Word

Hi All,

This is Madhu again and here my doubt is that,We have

export Array method to get excel data as a object right?

The code, what I have is

Object dataTable [][] = worksheet.getCells().exportArray(74,7,54,6);

How can I send this object to word document as it is?

Is it possible or not?

If yes how can I achieve it?

Please help me ...

It is the last issue in my project using Aspose.

I need to place the exportArray object in word.

Or some merged cells data.

Thanks

Madhu

Hi

Thanks for your inquiry. I think the following code could help you.

//Open excel workbook

Workbook excelWorkBook = new Workbook();

excelWorkBook.open("in.xls");

//Get worksheet from workbook

Worksheet sheet = excelWorkBook.getWorksheets().getSheet(0);

//Get array

Object dataTable [][] = sheet.getCells().exportArray(0, 0 , 4, 5);

//Create new document and DocumentBuilder

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//build table from Object array

for(int rowIdx=0; rowIdx<dataTable.length; rowIdx++)

{

for(int colIdx=0; colIdx<dataTable[rowIdx].length; colIdx++)

{

builder.insertCell();

builder.write(String.valueOf(dataTable[rowIdx][colIdx]));

}

builder.endRow();

}

builder.endTable();

//Save output document

doc.save("out.doc");

Best regards.

Hi Alexey,
thanks for your reply.

I will just check it out and let you know the feedback.

Thanks

Madhu

Hi alexey,

I have one doubt.

How can I insert a document at a paticular location in another document.

Suppose I have a word document with some data and I want to insert some new data( or it will be object kind of thing like graph ..),which will get from excel using above code, at a particular location or page in that word document.

How could I made it.

Help me out.

Thanks

Madhu

Hi

Thanks for your inquiry. You can use DocumentBuilder MoveToXXX methods to move the document builder's cursor to a particular place or element in the document in order to insert there necessary elements after. See the documentation for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/moving-to-document-elements.html

Best regards.

Hi Alexey,

Thanks and I will let you know the status

Thanks

Madhu