create Excel file - snippet
http://www.codepal.co.uk/show/Line_breaks_lost_and_br_tags_show_when_exporting_to_Excel_file
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Dim dt As New DataTable
dt.Columns.Add(New DataColumn("Text1", GetType(System.String))) Dim dr As DataRow = dt.NewRow
dr.Item("Text1") = String.Format("This is line one{0}This is line two{0}This is line three", "<br/>")
dt.Rows.Add(dr) Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=exported.xls")
Response.AddHeader("Pragma", "public")
Response.AddHeader("Cache-Control", "max-age=0")
Response.ContentType = "application/vnd.ms-excel"
Response.ContentEncoding = System.Text.Encoding.UTF8 Dim gvEx As New GridView
gvEx.AutoGenerateColumns = True
gvEx.AllowSorting = False
gvEx.AllowPaging = False
Dim sw As New System.IO.StringWriter
Dim hw As New System.Web.UI.HtmlTextWriter(sw)
gvEx.DataSource = dt
gvEx.DataBind()
hw.AddAttribute("xmlns:x", "urn:schemas-microsoft-com:office:excel") ' optional'
hw.RenderBeginTag(HtmlTextWriterTag.Html)
hw.RenderBeginTag(HtmlTextWriterTag.Head)
hw.RenderBeginTag(HtmlTextWriterTag.Style)
hw.Write("br {mso-data-placement:same-cell;}")
hw.RenderEndTag() ' /Style'
hw.RenderEndTag() ' /Head'
hw.RenderBeginTag(HtmlTextWriterTag.Body)
gvEx.RenderControl(hw)
hw.RenderEndTag() ' /Body'
hw.RenderEndTag() ' /Html'
Response.Write(HttpUtility.HtmlDecode(sw.ToString)) ' turns <br/> back into <br/>'
Response.Flush()
Response.End() End Sub
create Excel file - snippet的更多相关文章
- How to create Excel file in C#
http://csharp.net-informations.com/excel/csharp-create-excel.htm Before you create an Excel file in ...
- Formatting Excel File Using Ole2 In Oracle Forms
Below is the some useful commands of Ole2 to format excel file in Oracle Forms.-- Change font size a ...
- NetSuite SuiteScript 2.0 export data to Excel file(xls)
In NetSuite SuiteScript, We usually do/implement export data to CSV, that's straight forward: Collec ...
- csharp:using OpenXml SDK 2.0 and ClosedXML read excel file
https://openxmlexporttoexcel.codeplex.com/ http://referencesource.microsoft.com/ 引用: using System; u ...
- Creating Excel File in Oracle Forms
Below is the example to create an excel file in Oracle Forms.Pass the Sql query string to the below ...
- Read / Write Excel file in Java using Apache POI
Read / Write Excel file in Java using Apache POI 2014-04-18 BY DINESH LEAVE A COMMENT About a year o ...
- The 13th tip of DB Query Analyzer, powerful processing EXCEL file
The 13thtip of DB Query Analyzer, powerful processing EXCEL file MA Genfeng (Guangdong UnitollServic ...
- A simple way to crack VBA password in Excel file
Unbelivibale, but I found a very simple way that really works! Do the follwoing: 1. Create a new sim ...
- C# How To Read .xlsx Excel File With 3 Lines Of Code
Download Excel.zip - 9.7 KB Download ExcelDLL.zip - 3.7 KB Introduction We produce professional busi ...
随机推荐
- springcloud费话之Eureka集群
目录: springcloud费话之Eureka基础 springcloud费话之Eureka集群 springcloud费话之Eureka服务访问(restTemplate) springcloud ...
- 前端 ----- 初探ES6 Promise
前段时间做项目,在调用接口的时候,遇到了异步问题.开始是使用定时器,发现效果并不理想,于是又用了回调,效果还好但是,很明显的影响了代码的整洁性. 于是我想起了在面试的那段时间,背过的面试题里,出现过一 ...
- XMPP即时通讯协议使用(八)——基于订阅发布实现消息流转业务泳道图
- 2018-2-13-WPF-延迟加载
title author date CreateTime categories WPF 延迟加载 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23:3 + ...
- shell --08 例子
目录 1.按照时间生成文件2018-05-22.log将每天的磁盘使用状态写入到对应日期的文件 [root@web01 ceshi]# cat 1.sh #!/bin/bash Date=`date ...
- web安全—tomcat禁用WebDAV或者禁止不需要的 HTTP 方法
现在主流的WEB服务器一般都支持WebDAV,使用WebDAV的方便性,呵呵,就不用多说了吧,用过VS.NET开发ASP.Net应用的朋友就应该 知道,新建/修改WEB项目,其实就是通过WebDAV+ ...
- Python3.5-20190519-廖老师-自我笔记-面向对象中slots变量--@property的使用
python是动态语言,可以随时随地给实例对象添加属性和方法,但是我们想限制属性的名字,可以使用__slots__特殊变量来限制 使用__slots__要注意,__slots__定义的属性仅对当前类实 ...
- vue 父组件数据修改,子组件数据未修改
页面: 父组件 <myfeedback></myfeedback> 子组件 <news></news> myfeedback.vue <te ...
- jupyter notebook 几个方法
2. Pretty Display of Varibles 这部分内容可能很多人都知道.如果对带有一个变量或是未赋值语句的cell执行操作,Jupyter 将会自动打印该变量而无需一个输出语句. 如果 ...
- java基础复习(二)
一. 基本语法 如果一个源文件中什么内容都没有,编译会不会生成 字节码文件?不会 如果一个类中没有主方法(如下图),编译运行会怎么样?编译可以通过,但运行报错 : 没有主方法 主方法 : 是一个特殊的 ...