Oct 23, 2014, 4:21 PM
Export data to excel with color
Hello !!
I have a GRID on my page, and one of the columns it has color.
For example:
If the field is equal to "24" the cell is green, if the field is "36 Hours" yellow.
I wonder how I export the Grid to excel with these colors according to the cell value.
And when I import to excel one column called Value with negative values that do not belong to my Store appears.
Follows the PRINT GRID and Excel file
I thank any help.
Button of Export
I have a GRID on my page, and one of the columns it has color.
For example:
If the field is equal to "24" the cell is green, if the field is "36 Hours" yellow.
I wonder how I export the Grid to excel with these colors according to the cell value.
And when I import to excel one column called Value with negative values that do not belong to my Store appears.
Follows the PRINT GRID and Excel file
I thank any help.
Button of Export
protected void StoreFechadosRTBCapital_Submit(object sender, StoreSubmitDataEventArgs e)
{
string format = this.FormatType.Value.ToString();
XmlNode xml = e.Xml;
this.Response.ContentType = "application/vnd.ms-excel";
this.Response.AddHeader("Content-Disposition", "attachment; filename=FechadosRTBCapital_" + DateTime.Now + ".xls");
XslCompiledTransform xtExcel = new XslCompiledTransform();
xtExcel.Load(Server.MapPath("~/App_Themes/CSS/Excel.xsl"));
xtExcel.Transform(xml, null, Response.OutputStream);
this.Response.End();
}
Store <ext:JsonReader IDProperty="Value">
<Fields>
<ext:RecordField Name="HISREPETIDA" SubmitEmptyValue="EmptyString" />
<ext:RecordField Name="LOCESCRITORIO" SubmitEmptyValue="EmptyString" />
<ext:RecordField Name="LOCAREA" SubmitEmptyValue="EmptyString" />
<ext:RecordField Name="FRACODSC" SubmitEmptyValue="EmptyString" />
<ext:RecordField Name="GESRESPONSABLE" SubmitEmptyValue="EmptyString" />
<ext:RecordField Name="LOCNOTERMINAL" SubmitEmptyValue="EmptyString" />
<ext:RecordField Name="DT_RECLAMACAO" Type="Date" SubmitEmptyValue="EmptyString">
<Convert Handler="return Ext.util.Format.date(value,'d/m/Y H:i:s')" />
</ext:RecordField>
<ext:RecordField Name="DT_PRE_BAIXA" Type="Date" SubmitEmptyValue="EmptyString">
<Convert Handler="return Ext.util.Format.date(value,'d/m/Y H:i:s')" />
</ext:RecordField>
<ext:RecordField Name="HORAS" Type="Float" SubmitEmptyValue="EmptyString">
</ext:RecordField>
<ext:RecordField Name="PRAZO" SubmitEmptyValue="EmptyString"/>
</Fields>
</ext:JsonReader>
Excel.xsl<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<xsl:template match="/">
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:apply-templates/>
</Workbook>
</xsl:template>
<xsl:template match="/*">
<Worksheet>
<xsl:attribute name="ss:Name">
<xsl:value-of select="local-name(/*/*)" />
</xsl:attribute>
<Table x:FullColumns="1" x:FullRows="1">
<Row>
<xsl:for-each select="*[position() = 1]/*">
<Cell><Data ss:Type="String">
<xsl:value-of select="local-name()" />
</Data></Cell>
</xsl:for-each>
</Row>
<xsl:apply-templates/>
</Table>
</Worksheet>
</xsl:template>
<xsl:template match="/*/*">
<Row>
<xsl:apply-templates/>
</Row>
</xsl:template>
<xsl:template match="/*/*/*">
<Cell><Data ss:Type="String">
<xsl:value-of select="." />
</Data></Cell>
</xsl:template>
</xsl:stylesheet>