Coder Social home page Coder Social logo

Comments (7)

mk-j avatar mk-j commented on May 13, 2024

Can you narrow it down to which row is causing the issue, and put it in code? For instance:

include_once("xlsxwriter.class.php");
$my_string = "\xa35";//35 pounds (currency)
$my_string = mb_convert_encoding($my_string, 'UTF-8', 'windows-1252');
$writer = new XLSXWriter();
$writer->writeSheetRow('Sheet1', array($my_string) );
$writer->writeToFile('output.xlsx');

when I comment out mb_convert_encoding() above, and run this via command line php, i get this from stderr:
2014-11-14 20:58:44:Error, invalid UTF8 encoding detected.
But when I leave mb_convert_encoding() in there, the (above) spreadsheet seems to work for me.

What version of PHP?
What server is running PHP? (windows, linux, etc)
Is the .xlsx file a valid .zip file (can you rename it to .zip and unzip it, and the zip is not corrupted?)

from php_xlsxwriter.

seattledeveloper avatar seattledeveloper commented on May 13, 2024

I did copy the data over to my test server and went through it row by row. Here's the issue. I have a product model number "500E1205", which I have put in a column that is specified as a string. Unfortunately, either your code or Excel is seeing this as a number and I get a INF in the field where this should be located. Is there any way that your code can say this is truly a string? I noticed that your interpretation of cell contents uses a !is_string() call on line 233. Could this be viewed as a number by PHP when in reality it should be specified as a string when exported to Excel? So it turned out that it might not have had anything to do with character encoding.

BTW, I am using PHP 5.4.32 running on CentOS as an Apache module. And this .xlsx is a valid zip file. That's the first thing I checked before writing.

from php_xlsxwriter.

mk-j avatar mk-j commented on May 13, 2024

Just committed a fix for that, let me know if it works for you.

from php_xlsxwriter.

seattledeveloper avatar seattledeveloper commented on May 13, 2024

I downloaded and tested on both my test environment and in production and both worked great. Thanks very much for your quick fix!

from php_xlsxwriter.

seattledeveloper avatar seattledeveloper commented on May 13, 2024

Thanks. And thanks again for your quick work on this!

from php_xlsxwriter.

amitrana-dev avatar amitrana-dev commented on May 13, 2024

Not sure if i am doing anything wrong, because got the same error with just writing following headers.

Array
(
    [Status] => string
    [Part Number] => string
    [Model Number] => string
    [Serial Number] => string
    [Manufacturer] => string
    [Condition] => string
    [Vendor] => string
    [Price] => string
    [Purchase Date] => string
    [Warranty Date] => string
    [Calibration Date] => string
)

Code i am using to generate is this:

// $theader output is above
$writer->writeSheetHeader('Sheet1', $theader );
header('Content-disposition: attachment; filename="'.$filename.'"');
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header('Content-Transfer-Encoding: binary');
$writer->writeToStdOut();

Edit: Ignore it, My problem was due to single space being printing before file output.

from php_xlsxwriter.

mk-j avatar mk-j commented on May 13, 2024

This should be fixed properly in the latest version 0.30

from php_xlsxwriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.