0

I am not able to set any data after each column,suppose i have column like a1,a2,a3 i am able to set only for a1 and a3 not a2.I am using aspose to set data in xml and generate xml.What is wrong i am doing here ?

Worksheet workSheet = workerBook.getWorksheets().get(0);
style.setTextWrapped(true);
workSheetCell = workSheet.getCells().get("A1");
workSheet.getCells().merge(3, 0, headerRows, 1);
workSheet.getCells().merge(3, 1, headerRows, 1);
workSheet.getCells().merge(3, 2, headerRows, 1);
// workSheet.getCells().get("C4").putValue("Time");
workSheet.getCells().get("A4").putValue("Respondent");

workSheet.getCells().get("B4").putValue("Date");

workSheet.getCells().get("C4").putValue("Time");

The string "Date is not getting set in xml" generated.Please let me know what is wrong here.This is done using aspose.

pars
  • 153
  • 2
  • 4
  • 11

2 Answers2

0

As per my current understanding, the above specified code is not compact, it has some pointers/objects for which I am not sure. Also please share some further details regarding this issue.

However I have tested this scenario with the following sample code (similar to the one you are using) with Aspose.Cells for Java v7.3.2, and it works fine. The "Date" and "Time" values are inserted fine into the merged B4 and C4 cells.

int headerRows = 3;
Workbook workerBook = new Workbook();  
Worksheet workSheet = workerBook.getWorksheets().get(0);
//style.setTextWrapped(true);
Cell workSheetCell = workSheet.getCells().get("A1");
workSheet.getCells().merge(3, 0, headerRows, 1);
workSheet.getCells().merge(3, 1, headerRows, 1);
workSheet.getCells().merge(3, 2, headerRows, 1);
// workSheet.getCells().get("C4").putValue("Time");
workSheet.getCells().get("A4").putValue("Respondent");
workSheet.getCells().get("B4").putValue("Date");
workSheet.getCells().get("C4").putValue("Time");
workerBook.save("SettingData.xlsx");
workerBook.save("myoutputSettingData.xml", SaveFormat.SPREADSHEET_ML);

Take a look over following image which shows the resultant workbook.enter image description here

PS, I am working as Support Developer / Technical Evangelist at Aspose.

codewarior
  • 441
  • 2
  • 9
  • i am using aspose7.0.0.The Data in headerRow is either 3/2.Apart from that my code is same as yours .I am not sure what is worng – pars Oct 10 '12 at 14:29
  • I want to generate excel sheet not xml – pars Oct 10 '12 at 14:38
  • @codearior i am using openOffice and the extension is .xlkx.Please help m to resolve this issue – pars Oct 10 '12 at 14:45
0

@pars, I am afraid I am not certain about .xlkx extension which you have referred above, and the closest extension is .xltx. I have generated the xltx file using the same code below after modifying the last line.

Sample Code.

int headerRows = 3;
Workbook workerBook = new Workbook();  
Worksheet workSheet = workerBook.getWorksheets().get(0);
//style.setTextWrapped(true);
Cell workSheetCell = workSheet.getCells().get("A1");
workSheet.getCells().merge(3, 0, headerRows, 1);
workSheet.getCells().merge(3, 1, headerRows, 1);
workSheet.getCells().merge(3, 2, headerRows, 1);
// workSheet.getCells().get("C4").putValue("Time");
workSheet.getCells().get("A4").putValue("Respondent");
workSheet.getCells().get("B4").putValue("Date");
workSheet.getCells().get("C4").putValue("Time");
workerBook.save(DIR + "SettingData.xltx", SaveFormat.XLTX);

Can you please test the latest version as I am unable to notice problem with the latest release Aspose.Cells for Java v7.3.2.2 - Latest Version. The xltx file which I have generated, can be accessed from this link.

Following image shows the file being viewed in OpenOffice. enter image description here

codewarior
  • 441
  • 2
  • 9