Git Product home page Git Product logo

as3xls's Introduction

Hello!

This is my fork of as3xls โ€” an Excel library for Actionscript 3. Here I've fixed a number of bugs in the XLS-reading portions of the code.

At the moment I have no need for the XLS-writing parts, so won't be maintaining them. I'm happy to receive patches though!

as3xls's People

Contributors

darl2ng avatar ttalbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

as3xls's Issues

Can't write Korean language

hi,

Thank's for your work but I can't write Korean language through the library :/
I've tried to change the way strings are converted to Byte (by modifying the "cell.data.writeMultiByte(value, charset);" of "saveToByteArray" method) but there is no way.

Thanks for your help.

Does not support references to other worksheets

It appears that formulas referencing other sheets are not supported ... This is really sad if you are using huge XLS-Files with lots of different sheets.

It would be awesome if someone can fix this problem/bug. I would even pay for a solution and we can post it here at github!

How do I use it ?

This is not an issue but I am a newbie to Flex and I am not sure how I should be using this. Do I have to compile this to a swc file? If so how do I compile ? Can someone please provide me instructions.

Thanks.

Cannot read date cell formate in Excel 2003 file

I have a file generated by Excel 2003. It only contain a column which is date. When I display it using the library, I can only see Integer. After checking the type of the cell is not Data and then cause error. please check

Not writing multiple sheets.

What steps will reproduce the problem?

  1. Create new Excel file and add 2 or more sheets to it:

var excelFile:ExcelFile = new ExcelFile();
var sheet1:Sheet = new Sheet();
sheet1.resize(10,10);
sheet1.setCell(0,0,"Blah");
excelFile.sheets.addItem(sheet1);
var sheet2:Sheet = new Sheet();
sheet2.resize(10,10);
sheet2.setCell(0,0,"Whatever");
excelFile.sheets.addItem(sheet2);

  1. Save the Excel file to a byte array and save as an .xls file:

var byteArray:ByteArray = excelFile.saveToByteArray();
Var fileRef:FileReference = new FileReference();
fileRef.save(byteArray,"test.xls");

  1. Open the new .xls file in Excel.

What is the expected output? What do you see instead?

Expect to see an Excel spreadsheet with 2 sheets. See an Excel spreadsheet
with one sheet (with first cell containing "Blah");

What version of the product are you using? On what operating system?

Version of as3xls.swc downloaded on March 26 2009.
Adobe Flex Bulder version 3.0
Flash Player version 10.0.22
Windows Server 2003 version 5.2 R2
Please provide any additional information below.

Comment 1 by [email protected], Aug 27, 2009
Hi

We are using the library to export xls files and we need to export more than one
sheet only. It's a shame that a wonderful library like this has this defect so I'm
trying to solve it.

The problem seems to be there in the ExcelFile.as

public function saveToByteArray():ByteArray {
var s:Sheet = _sheets[0] as Sheet;

        var br:BIFFWriter = new BIFFWriter();

        // Write the BOF and header records
        var bof:Record = new Record(Type.BOF);
        bof.data.writeShort(BIFFVersion.BIFF2);
        bof.data.writeByte(0);
        bof.data.writeByte(0x10);
        br.writeTag(bof);

....etc

It seems that the method saveToByteArray() only exports the first sheet (var s:Sheet
= sheets[0] as Sheet;) in the excel file you have defined, wich has all the sheets
in the
sheets Array.

I'm playing with the output data looping the _sheets array but however the file size
is the double with two pages that with one I'm getting an error of the excel program
saying maybe I lost some data and outputing only one page.

I'm not experienced with ByteArray and I don't know if I could fix it.

Some one helps with this??

Thank you in advance.

Comment 2 by [email protected], Aug 27, 2009
My try:

public function saveToByteArray():ByteArray {
var br:BIFFWriter = new BIFFWriter();

        for(var v:int=0;v<_sheets.length;v++){
            var s:Sheet = _sheets[v] as Sheet;

            // Write the BOF and header records
            var bof:Record = new Record(Type.BOF);
            bof.data.writeShort(BIFFVersion.BIFF2);
            bof.data.writeByte(0);
            bof.data.writeByte(0x10);
            br.writeTag(bof);

            // Date mode
            var dateMode:Record = new Record(Type.DATEMODE);
            dateMode.data.writeShort(1);
            br.writeTag(dateMode);

            // Store built in formats
            var formats:Array = ["General", 
                "0", "0.00", "#,##0", "#,##0.00", 
                "", "", "", "",
                "0%", "0.00%", "0.00E+00",
                "#?/?", "#??/??",
                "M/D/YY", "D-MMM-YY", "D-MMM", "MMM-YY"];

            var numfmt:Record = new Record(Type.BUILTINFMTCOUNT);
            numfmt.data.writeShort(formats.length);
            br.writeTag(numfmt);

            for(var n:uint = 0; n < formats.length; n++) {
                var fmt:Record = new Record(Type.FORMAT);
                fmt.data.writeByte(formats[n].length);
                fmt.data.writeUTFBytes(formats[n]);
                br.writeTag(fmt);
            }

            var dimensions:Record = new Record(Type.DIMENSIONS);
            dimensions.data.writeShort(0);
            dimensions.data.writeShort(s.rows+1);
            dimensions.data.writeShort(0);
            dimensions.data.writeShort(s.cols+1);
            br.writeTag(dimensions);

            for(var r:uint = 0; r < s.rows; r++) {
                for(var c:uint = 0; c < s.cols; c++) {
                    var value:* = s.getCell(r, c).value;
                    var cell:Record = new Record(1);
                    cell.data.writeShort(r);
                    cell.data.writeShort(c);

                    if(value is Date) {
                        var dateNum:Number = 

(value.time / 86400000) + 24106.667;
cell.type = Type.NUMBER;
cell.data.writeByte(0);
cell.data.writeByte(15);
cell.data.writeByte(0);

cell.data.writeDouble(dateNum);
} else if(isNaN(Number(value)) ==
false && String(value) != "") {
cell.type = Type.NUMBER;
cell.data.writeByte(0);
cell.data.writeByte(0);
cell.data.writeByte(0);
cell.data.writeDouble(value);
} else if(String(value).length > 0) {
cell.type = Type.LABEL;
cell.data.writeByte(0);
cell.data.writeByte(0);
cell.data.writeByte(0);
var len:uint =
String(value).length;
cell.data.writeByte(len);

cell.data.writeUTFBytes(value);
} else {
cell.type = Type.BLANK;
cell.data.writeByte(0);
cell.data.writeByte(0);
cell.data.writeByte(0);
}

                    br.writeTag(cell);
                }
            }

            // Finally, the closing EOF record
            if(v==_sheets.length-1){
                var eof:Record = new Record(Type.EOF);
                br.writeTag(eof);
            }
        }

        br.stream.position = 0;
        return br.stream;
    }

Result: File with double size and the data in the binary form of the second sheet is
there but excel don't recognize second sheet.

Issue and workaround with localized portuguese date with *

The dates are correctly parsed even with localizes dates except for Portuguese (Portugal) with the * type date.

However there is a workaround.

In the method xf of the ExcelFile.as file, replace the following block of code:

            case BIFFVersion.BIFF8:
                font = r.data.readUnsignedShort();
                format = r.data.readUnsignedShort();
                break;

By this one:

            case BIFFVersion.BIFF8:
                font = r.data.readUnsignedShort();
                format = r.data.readUnsignedShort();
                if (format == 14)
                    format = 165;
                break;

Issue and workaround with unsigned date

I have a xls file that I dont know how as created but have a date cell that appears as Portuguese (Portugal) with * but is now seems that internally its now a date !

The only workaround that I found (and tested with several date formats in separated and in the same file):

In the method loadFromByteArray of the ExcelFile.as, put:

currentSheet.formats[165] = "yyyy/mm/dd;@";

After the currentSheet = new Sheet();

This will ensure that the date format is always present in the formats array even if that format is not recognized in the excel file.

cant read cell over 99

trace("99:"+sheet.getCell(99,1))
trace("100:"+sheet.getCell(100,1))
trace("101:"+sheet.getCell(101,1))

result:
99:99
100:
101:

please help me!

Length of Labels are longer than 256

Thanks for your work, this lib helps me a lot.
I'm wondering how to append more characters into a single cell if their length is longer than a byte. I've tried inputing a two-byte length but failed although it seems to be acceptable according to a spec written by someone from Open Office. Appreciated for any help. Thanks.

Issues parsing formulas involving dates

I have a column of dates that don't get parsed correctly because they're in formula form and they're all =A#+30 (the pound sign is just a number). This should add 30 days to each date but instead comes up with messed up stuff. When I trace out the output of the object i get:

Some Date:Thu Sep 27 00:00:00 GMT-0500 1900:(com.as3xls.xls.formula::Formula)#0
formula = "=S141+30"
myCol = 19
myRow = 140
result = "30Mon Aug 18 00:00:00 GMT-0400 2008"

Looking through the code to see how I can fix but I'm new to this library so it's taking me a bit to isolate where I can fix this. Ideas?

Exporting Number 0878 to Excel as Text, loses starting 0

Hi,

Can't figure out how to export a Number with an initial 0 to Excel. For example :

if I want the cell to contain 0989

I do:

cell = sheet.getCell(currentRow, currentColumn);
cell.format = "text";
sheet.setCell(currentRow, currentColumn,cell.value);

But in Excel the value comes out as 989 and is stored in General Format.

There aren't any docs tat explain exatly how to use the .format property.

I also have other cells that I want to set in the number format, but cant seem to work that out either.

Any Ideas?

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.