Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating 'xls' file
Forum Updated to NodeBB v4.3 + New Features

Creating 'xls' file

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khalistan
    wrote on last edited by
    #1

    I want to create xls file. I am using this code:-
    Void MainWindow::test(){

    QFile file("hello.xls");
    if (file.open(QFile::WriteOnly|QFile::Truncate))
    {
    QTextStream stream(&file);
    stream << "ID" << "\t" << "Date<< "\t" <<"SOFTWARE-Version"<< "\t"<<"UserName";
    file.close();
    }
    }

    So it is creating file hello.xls but if I open this file then Excel is giving this error:

    Excel has detected that 'hello.xls' is a SYLK file, but cannot load it. Either the file has error or it is not a SYLK file format. .....

    What is correct way to make excel file with ',xls' format?

    Thanks for help

    kshegunovK 1 Reply Last reply
    0
    • K khalistan

      I want to create xls file. I am using this code:-
      Void MainWindow::test(){

      QFile file("hello.xls");
      if (file.open(QFile::WriteOnly|QFile::Truncate))
      {
      QTextStream stream(&file);
      stream << "ID" << "\t" << "Date<< "\t" <<"SOFTWARE-Version"<< "\t"<<"UserName";
      file.close();
      }
      }

      So it is creating file hello.xls but if I open this file then Excel is giving this error:

      Excel has detected that 'hello.xls' is a SYLK file, but cannot load it. Either the file has error or it is not a SYLK file format. .....

      What is correct way to make excel file with ',xls' format?

      Thanks for help

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @khalistan

      Here:
      http://download.microsoft.com/download/2/4/8/24862317-78F0-4C4B-B355-C7B2C1D997DB/[MS-XLSB].pdf

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        XLS is a binary format and its complex to generate.

        this
        stream << "ID" << "\t" << "Date<< "\t" <<"SOFTWARE-Version"<< "\t"<<"UserName";

        makes a CSV file
        excel like tabs so it should just work.

        You cannot just change the file name to .XLS that can never work.

        1 Reply Last reply
        0
        • yafilecosaY Offline
          yafilecosaY Offline
          yafilecosa
          wrote on last edited by
          #4

          Do you want to create only xls file, not xlsx?

          If you interesting to create xlsx files , just use very nice library QtXlsxWriter.
          https://github.com/dbzhang800/QtXlsxWriter

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved