Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:00:22+00:00 2026-06-11T02:00:22+00:00

I can upload and convert CSV files by Drive API without any problem, but

  • 0

I can upload and convert CSV files by Drive API without any problem,
but when sending XLS (rendered with PEAR XLS-Writer) or XLSX (rendered with PHPExcel) the Drive API complains:

"Error calling POST https://www.googleapis.com/upload/drive/v2/files?convert=true&uploadType=multipart&key=123: (500) Internal Error"

MIME type “application/vnd.ms-excel” apparently works better than “application/vnd-excel”

When I write out XLSX with content-type “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet” it’s quite the same …
it gets stuck when loading the preview, when convert=true.

When creating files with MS Excel and uploading them manually it works fine.

I can insert/update, download/open the files (all fine) – but I want to convert them.

With all the tests performed I guess the problem is related to the created file-format – or MIME type.

Any hints why the conversion might fail…

“Did ever someone managed to convert rendered XLS/XLSX?”

The question basically is: What is the expected file-format + MIME-type in order to convert to gSheet?

I’d accept any answer for the bounty, which provides a way to convert a multi-dimensional array to gSheet with several pages, in case it’s not (yet) possible via the Drive API (for sure that would be the preferred way).

This is a Google Drive API question – there’s just no individual tag for this available.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:00:23+00:00Added an answer on June 11, 2026 at 2:00 am

    Most fast-forward was to render array to Excel 2007 and just install Google Drive App on the Desktops for accessing the data. Spreadsheets API can’t create documents, need to do that with Docs API; Currently the API wrapper for PHP not supports both of these endpoints – like this I can revision the files as well. Timely effort: 1h.

    Update: When I render XLSX with Excel2007 the conversion fails. When I open the very same file with MS-Excel and “Save As” – I can convert it even over the Drive API.

    I noticed some things when unzipping the files and compared:

    a) MS-Excel uses values ‘0/1’ instead of ‘false/true’

    b) Directory ‘xl/worksheets/_rels’ got removed (maybe useless?).

    c) The line-endings of the XML´s were converted from UNIX to DOS.

    d) MS-Excel added all the empty cells to the XML – which PHPExcel didn’t write out.

    e) the relation IDs appear to be shifted … there some +3 calculation in code??

    The problem is, that the generated file-format is not matching the Drive API’s XML-parser.

    I’m still not exactly sure what is wrong with the generated file-format,
    but patching the rendered XLSX file with XML files natively created by MS-Excel makes it work:

    /* how-to patch the generated XLSX: */
    
    $zip = new ZipArchive();
    $zip->open($xlsx_path);
    $zip->extractTo($export_dir.'temp');
    $zip->close();
    
    $this->deleteDir($export_dir.'temp/xl/worksheets/_rels');
    
    $files =array(
       '_rels/.rels',
       'docProps/app.xml',
       'docProps/core.xml',
       'xl/workbook.xml',
       'xl/_rels/workbook.xml.rels',
       'xl/theme/theme1.xml'
    );
    foreach($files as $file){
       copy($export_dir.'template/'.$file, $export_dir.'temp/'.$file);
    }
    
    unlink($xlsx_path);
    
    if($zip->open($xlsx_path, ZIPARCHIVE::CREATE)) {
    $source = str_replace('\\', '/', realpath($export_dir.'temp'));
    if(is_dir($source) === true) {
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
        foreach ($files as $file) {
            $file = str_replace('\\', '/', $file);
            if(in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) ){continue;}
            $file = realpath($file);
            if(is_dir($file) === true){$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));}
            else if(is_file($file) === true){
                  $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
               }
            }
        }
        else if(is_file($source) === true) {
           $zip->addFromString(basename($source), file_get_contents($source));
        }
        $zip->close();
    }
    

    The cell formatting isn’t too proper – but the conversion & preview is working.

    Can even skip some XML files from patching, some others make it break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do a simple file upload page but keep getting can't convert
I have a web page on which users can upload text files (but a
As part of a web application users can upload files of data, which generates
I have a system where employees can upload files. There are three ways Upload
If I have form where user can upload files via Ajax (and upload is
how can i upload and convert the video to mp4 behind the scene so
Is there any public service which I can use to convert any of the
I need to convert mp3 files into mp4 or any other video formats, with
I am looking for a php module able to convert CDR files in any
I have a fileupload control where i can upload xml documents. The XML files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.