Boa tarde pessoal tou aqui com um pequeno problema.

Tenho uma função para exportar uma datagrid directamente do flex para Excel,
mas tá-me a dar uns problemas de encoding. Tudo o que é assentos e cedilhas
vem em formato esquesito.
Alguém tem ideia de como se resolve ? Procurei mas não encontrei nada.
Obrigado pela atenção

O código está de seguida:


public function convertDGToHTMLTable(dg:*, texto:String):void
            {
                str = texto;

                var font:String = dg.getStyle('fontFamily');
                var size:String =
(int(dg.getStyle('fontSize'))-2).toString(); //Reduz em 2, o tamanho da
fonte.

                var colors:String = '';
                var style:String =
'style="font-family:'+font+';font-size:'+size+'pt;"';
                var hcolor:Array;

                if(dg.getStyle("headerColor") != undefined) {
                    hcolor = [dg.getStyle("headerColor")];
                } else {
                    hcolor = dg.getStyle("headerColors");
                }

                str+= '<table width="'+dg.width+'"><thead><tr
width="'+dg.width+'" style="background-color:#'
+Number((hcolor[0])).toString(16)+'">';

                for(var i:int = 0;i<dg.columns.length;i++) {
                    colors = dg.getStyle("themeColor");

                    if(dg.columns[i].headerText != undefined &&
dg.columns[i].visible == true) {
                        str+="<th
"+style+">"+dg.columns[i].headerText+"</th>";
                    } else if (dg.columns[i].visible == true) {
                        str+= "<th
"+style+">"+dg.columns[i].dataField+"</th>";
                    }
                }
                str += "</tr></thead><tbody>";
                colors = dg.getStyle("alternatingRowColors");

                for(var j:int =0;j<dg.dataProvider.length;j++) {

                    str+="<tr width=\""+Math.ceil(dg.width)+"\">";

                    for(var k:int=0; k < dg.columns.length; k++) {
                        if(dg.dataProvider.getItemAt(j) != undefined &&
dg.dataProvider.getItemAt(j) != null && dg.columns[k].visible == true &&
dg.columns[k].dataField != "Melhor") {
                            if(dg.columns[k].labelFunction != undefined &&
dg.columns[k].labelFunction != null && dg.columns[k].visible == true) {
                                str += "<td nowrap=\"nowrap\"
width=\""+Math.ceil(dg.columns[k].width)+"\"
"+style+">"+dg.columns[k].labelFunction(dg.dataProvider[j],dg.columns[k])+"</td>";
                            } else {
                                str += "<td nowrap=\"nowrap\"
width=\""+Math.ceil(dg.columns[k].width)+"\"
"+style+">"+dg.dataProvider.getItemAt(j)[dg.columns[k].dataField]+"</td>";
                            }
                        }
                    }
                    str += "</tr>";
                }
                str+="</tbody></table>";

                saveFile();
            }

            public function saveFile():void
            {
                saveFileRef = new FileReference();
                saveFileRef.
                saveFileRef.save(str,nome);
            }

-- 
Luís Medeiro Costa

Flex Front-End Developer
TLM: 963794560
MSN: [email protected]
Twitter: http://twitter.com/LTostas

-- 
Recebeu esta mensagem porque está inscrito no grupo "Mailing List da Comunidade 
Portuguesa de Rich Internet Applications - www.riapt.org" dos Grupos do Google.

Para publicar uma mensagem neste grupo, envie um e-mail para 
[email protected].
Para anular a inscrição neste grupo, envie um e-mail para 
[email protected].
Para ver mais opções, visite este grupo em 
http://groups.google.com/group/riapt?hl=pt-PT.

Responder a