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 ...
随机推荐
- 小Q的棋盘 (贪心)
小Q的棋盘 (贪心) 题目 洛谷传送门 做法 显然这是一棵树(这个就不多bb了,树的性质) 很容易发现一个性质,如果一条链走完,我们必须回头再走一次那条链(或一部分)才可以走到更多的点 所以为了减少这 ...
- hdu5943 Kingdom of Obsession 二分图+打表找规律
题目传送门 Kingdom of Obsession Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- Quartz实现数据库动态配置定时任务
项目实战 或许实现的方式跟之前的代码有点不一样的 1.定时任务的配置信息 @Configuration public class ScheduleConfigration { @Autowired p ...
- jsp页面必填项如何加红星号*
1.加*号 并且设置*号大小 <span style="color:red; font-size: 20px">*</span>
- vue-如何输出Hello world
首先引入vue.js文件 <script src="vue.js"></script> <!DOCTYPE html> <html> ...
- java 字符串获取
package java07; /* String 当中与获取相关的常用方法 public int length(); 获取字符串当中含有的字符的个数,得到字符串的长度 public String c ...
- Python3.5-20190526-廖老师-自我笔记-单元测试-参数换-paramunittest
参数化: import timeimport list1 #想测试list1中的求和函数是否正确fun1import paramunittestimport unittest #先设置参数组@para ...
- $Dsu$ $on$ $Tree$ 复习
\(Dsu\) \(on\) \(Tree\) 复习 发现最近有点头晕,突然这东西就不会了,头疼了很久,决定写一份记录啊. 大致认识 适用范围一般在处理树上子树统计问题,不支持在线回答询问以及修改. ...
- java编程实战
线程池为什么要有它: 线程创建要开辟虚拟机栈,释放线程要垃圾回收的. server端要并发访问数据库的. 服务器启动有线程池放着. ----- 线程池的概念: 1.任务队列 2.拒绝策略(抛出异常,直 ...
- Web核心之tomcat汤姆猫
web相关概念 1. 软件架构 1. C/S:客户端/服务器端 2. B/S:浏览器/服务器端 2. 资源分类 1. 静态资源:所有用户访问后,得到的结果都是一样的,称为静态资源.静态资源可以直接被浏 ...