PDA

View Full Version : [CLOSED] Export Store Excel Errror



ddeniz
May 08, 2014, 1:36 AM
Hi,

i trying exportgridpanel data to excel like this http://examples1.ext.net/#/GridPanel/Miscellaneous/Export_Data_Ajax/

but i getting error "Status Code: 200 Status Text: BADRESPONSE: Cannot read property 'documentElement' of null"

i don't know how to use export data with ajax
my codes like this;


<script type="text/javascript">
var submitValue = function(grid, hiddenFormat, format) {
hiddenFormat.setValue(format);
grid.submitData(false);
};

var template = '<span style="color:{0};">{1}</span>';

var change = function(value) {
return String.format(template, (value > 0) ? "green" : "red", value);
};

var pctChange = function(value) {
return String.format(template, (value > 0) ? "green" : "red", value + "%");
};
</script>

<ext:Hidden ID="FormatType" runat="server" />
<ext:GridPanel ID="myGrid" runat="server">
<Store>
<ext:Store ID="mySto_Submit" OnSubmitData="stoDetayMaliyet_Submit" RemoteSort="true"
runat="server" PageSize="50">
<Model>
<ext:Model ID="Model4" runat="server" IDProperty="ID">
<Fields>


<ext:ModelField Name="Price" Type="Float" />
<ext:ModelField Name="Desc" Type="Float" />

</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>

<ext:Column ID="Column11" runat="server" DataIndex="Desc" Width="40" Text="Desc" />

<ext:Column ID="Column17" runat="server" DataIndex="Price" Width="80" Text="Price"
Align="Right">
<Renderer Fn="Ext.util.Format.numberRenderer('0.0,00 /i')" />
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbar1" runat="server" />
</BottomBar>
<TopBar>

<ext:Button ID="Button3" runat="server" Text="To Excel" Icon="PageExcel">
<Listeners>
<CustomConfig>
<ext:ConfigItem Name="IsUpload" Value="true">
</ext:ConfigItem>
</CustomConfig>
<Click Handler="submitValue(#{myGrid}, #{FormatType}, 'xls');" />
</Listeners>
</ext:Button>

</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>

protected void mySto_Submit(object sender, StoreSubmitDataEventArgs e)
{
string format = this.FormatType.Value.ToString();

XmlNode xml = e.Xml;

this.Response.Clear();

switch (format)
{
case "xml":
string strXml = xml.OuterXml;
this.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xml");
this.Response.AddHeader("Content-Length", strXml.Length.ToString());
this.Response.ContentType = "application/xml";
this.Response.Write(strXml);
break;

case "xls":
this.Response.ContentType = "application/vnd.ms-excel";
this.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.xls");
XslCompiledTransform xtExcel = new XslCompiledTransform();
xtExcel.Load(Server.MapPath("/Excel.xsl"));
xtExcel.Transform(xml, null, Response.OutputStream);

break;

case "csv":
this.Response.ContentType = "application/octet-stream";
this.Response.AddHeader("Content-Disposition", "attachment; filename=submittedData.csv");
XslCompiledTransform xtCsv = new XslCompiledTransform();
xtCsv.Load(Server.MapPath("/Csv.xsl"));
xtCsv.Transform(xml, null, Response.OutputStream);

break;
}
this.Response.End();
}

Daniil
May 08, 2014, 6:57 AM
Hi @ddeniz,

Please edit the post wrapping the code in [CODE] tags, see #3:
forums.ext.net/showthread.php?10205

ddeniz
May 08, 2014, 7:58 AM
Hi @Daniil,

i solved with use postback method, but i can't convert float datatype excel dont accept decimal seperator(,)

my grid cell value like 123.456,07 but it's see 123456.07 and not number type,

how can i set number type in xsl file?

Daniil
May 09, 2014, 2:34 PM
Any chance you could follow our recommendation in the post #2?



my grid cell value like 123.456,07 but it's see 123456.07 and not number type,

how can i set number type in xsl file?

Started a new forum thread:
http://forums.ext.net/showthread.php?34381