I want to create a excel sheet .xls file using Qt. I found a examples in a book C++ GUI Programming with Qt4. so I copied and written as follows.

Qt Code:
  1. enum { MagicNumber = 0x7F51C883, RowCount = 10, ColumnCount = 5 };
  2.  
  3. bool MainWindow::writeFile()
  4. {
  5. QString fileName = "d:\\abc.xls";
  6. QFile file(fileName);
  7. if (!file.open(QIODevice::WriteOnly)) {
  8. QMessageBox::warning(this, tr("Spreadsheet"),
  9. tr("Cannot write file %1:\n%2.")
  10. .arg(file.fileName())
  11. .arg(file.errorString()));
  12. return false;
  13. }
  14. QDataStream out(&file);
  15. out.setVersion(QDataStream::Qt_4_3);
  16. out << quint32(MagicNumber);
  17. //QApplication::setOverrideCursor(Qt::WaitCursor);
  18. for (int row = 0; row < RowCount; ++row) {
  19. for (int column = 0; column < ColumnCount; ++column) {
  20. QString str = QString(tr("test%1%2").arg(row).arg(column));
  21. if (!str.isEmpty())
  22. out << quint16(row) << quint16(column) << str;
  23. }
  24. }
  25. //QApplication::restoreOverrideCursor();
  26. return true;
  27. }
To copy to clipboard, switch view to plain text mode 

now its writing data in .xls file but not writing in proper row and column.
how to write in proper row and column?

I am using Qt4.3.1 on win Xp