Ext.NET的GridPanel导出Excel
2016-07-20 17:05
405 查看
配置:
js:
VB:
Excel.xsl文件
<Buttons> <ext:Button runat="server" Text="导出为Excel" Icon="PageExcel" AutoPostBack ="true" OnClick ="ToExcel"> <Listeners> <Click Fn="SaveData"></Click> </Listeners> </ext:Button> </Buttons>
js:
var SaveData = function () { App.GridData.setValue(Ext.encode(App.OnlineRecordListPanel.getRowsValues({ selectedOnly: false }))); }
VB:
Public Sub ToExcel(sender As Object, e As EventArgs) Dim Detail As String = Me.GridData.Value.ToString Dim eSubmit As New StoreSubmitDataEventArgs(Detail, Nothing) Dim xml As XmlNode = eSubmit.Xml Me.Response.Clear() Me.Response.ContentType = "application/vnd.ms-excel" Me.Response.AddHeader("Content-Disposition", "attachment; filename=在线记录.xls") Dim xtExcel As New XslCompiledTransform xtExcel.Load(AppDomain.CurrentDomain.BaseDirectory & ("\Excel.xsl")) xtExcel.Transform(xml, Nothing, Me.Response.OutputStream) Me.Response.End() End Sub
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 < 9086 span class="hljs-attribute">ss:Type="String"> <xsl:value-of select="." /> </Data></Cell> </xsl:template> </xsl:stylesheet>
相关文章推荐
- LeakCanary: 让内存泄露无所遁形
- Java集合(7):HashMap
- nodejs URL 详解
- jstl的formatNumber标签的四舍五入问题
- HTML5 sessionStorage会话存储
- 2016暑期集训---搜索(简单BFS+路径储存)
- eclipse联系关系的源码(重新关联源码)
- Facebook的强大Android图片加载的框架:Fresco
- 欢迎使用CSDN-markdown编辑器
- 人于岸江行-云田一品
- python模块
- PHP查询数据库中表是否存在 方法
- 利用均值漂移实现图像分割的原理和OpenCV代码
- SWTBot
- mysql手工注入总结
- 剑指offer——把字符串转换成整数
- 条码识别
- hdoj 3333 Turing Tree 【树状数组】
- RMQ
- js报错:TypeError: document.GetElementById is not a function