djw / as3xls Goto Github PK
View Code? Open in Web Editor NEWFork of as3xls with bugfixes (unmaintained)
Home Page: http://code.google.com/p/as3xls/
Fork of as3xls with bugfixes (unmaintained)
Home Page: http://code.google.com/p/as3xls/
Try with the cell with at least 4K characters in there. It exports to excel fine, but when opening from MS Excel program, it found unreadable content.
Thanks.
The file generated by this library cannot be read by this library
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.
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.
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?
Greetings, I am developing an application in adobe air, when I import the excel file throws me the following error: Error # 2030, I am using the code (http://active.tutsplus.com/tutorials/flex/using-as3xls-with -the-flex-framework-excel-import /) and online is fine, but I think the problem has to do with the code on your desktop with AIR
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;
For example in (A,1) on excel i have formattaed with bold character, how can i read it with as3xls?
thanks!
What steps will reproduce the problem?
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);
var byteArray:ByteArray = excelFile.saveToByteArray();
Var fileRef:FileReference = new FileReference();
fileRef.save(byteArray,"test.xls");
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.
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
What is the type of the license ?
This could be used in non-free projects ?
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.
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.
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?
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!
you know the drill
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.