« Announcing IPP v2.8 | Main | A letter from the CEO »

June 01, 2010

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a010535c544f3970c01348036da07970c

Listed below are links to weblogs that reference Flex to Excel or Excel to Flex, now that is the question!:

Comments

Bill

Great walk through! I'm using it primarily for export to excel only. One issue that I am running into is the fact that the first time I export, things export just fine (right number of columns and rows) but each subsequent time I run it, additional columns for the data gets added. For example if my datagrid and provider has 5 columns and 5 rows, first time I run it, I get an excel file with a 5 by 5 data that I'm expecting. The second time I run it, I get an excel file with 10 columns and 5 rows(only first 5 have headings), 3rd time I run it, I get 15 columns and 5 rows... so on and so on. Any suggestions on what may be causing the issue? I've gone in and set the variables to null first and them set them to the length of the arrays but same issue.

William Lorfing

Bill, I am not sure.

Does this only happen when you try it multiple times without closing the program or does it happen after closing the program and restarting?

If the program is still running, it sounds like something isn't getting cleared or reset before the next round.

Bill

Thanks for the reply William. It only happens when I try multiple times without closing out the program. If I hit refresh on my browser to reload the flex app, the first time I run the function, it works as expected. Just when I export again without reloading the app is when the duplication occurs.

Bill

William - think I found the culprit. Looks like the fields array isn't cleared each time the exportToExcel() is called so with each additional run, it appends the data to the array. I added a fields = new Array() in the exportToExcel() function and seems to work properly now.

Shaning

I tried but got failed at

excelFile.loadFromByteArray(fileData); // in fileReference_Complete(event:Event):void

(handlers[r.type] as Function).call(this, r, currentSheet); // in ExcelFiles.loadFromByteArray()

and

// in ExcelFiles
private function builtinfmtcount(r:Record, s:Sheet):void {
var numBuildInFormats:uint = r.data.readUnsignedShort();
}

William Lorfing

Can you explain more about what the problem is or what error message you are getting?

William

Amar

Will Export to excel work for multiple sheets?

William Lorfing

You should be able to.

You should be able to change the
var sheet:Sheet = excelFile.sheets[0];

to the next sheet.

William

ivan jacobs

Hey thx for this. I have issue with multiple sheets.
When I save to excel only one sheet is visible. In the debug there is a array of sheets but in the excel file only the first shows
var xls:ExcelFile = new ExcelFile();
xls.sheets.addItemAt(sheet,0);
xls.sheets.addItemAt(sheet2,1);
xls.sheets.addItemAt(sheet3,2);
//var bytes: ByteArray = xls.saveToByteArray();
var fr:FileReference = new FileReference();
fr.save(xls.saveToByteArray(),"SampleExport.xls");
}

madhu

hi,

i am exporting and importing with above code and geting the error while importing exported file.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.