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 ...
随机推荐
- 1、引言(Introduction)
1.1 欢迎 在生活中用到的机器学习算法: (1)打开谷歌.必应搜索到你需要的内容,正是因为他们有良好的学习算法 (2)每次您阅读您的电子邮件垃圾邮件筛选器,可以帮你过滤大量的垃圾邮件 机器学习为什么 ...
- 使用onfocus与onblur实现搜索框附加信息
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 并行开发 2.plink
原文:8天玩转并行开发——第二天 Task的使用 在我们了解Task之前,如果我们要使用多核的功能可能就会自己来开线程,然而这种线程模型在.net 4.0之后被一种称为基于 “任务的编程模型”所冲击, ...
- Spring学习笔记(14)——SpEL
是什么 Spring表达式语言全称为"Spring Expression Language",缩写为"SpEL",类似于Struts2x中使用的OGNL表达式语 ...
- 2019-1-5-Windows-的-Pen-协议
title author date CreateTime categories Windows 的 Pen 协议 lindexi 2019-01-05 11:14:49 +0800 2019-01-0 ...
- android5.1修改系统默认音量
在做定制需求的时候,需要修改系统通知的声音,将其禁用掉,避免第三方应用发送通知时,声音很大,吓着用户.索性就把通知声音关掉.下面就说说关闭声音的几种方法,以及修改系统默认声音的方法. 1. 直接修改系 ...
- 记一次sql索引颠覆认知
首先先建立数据库和插入数据 我们要查询的命令如下,前提是以mysql数据库为准 , 结果和我想的不太一样,先准备好环境和所需的数据库和表 准备阶段 CREATE TABLE `test` ( `id` ...
- mysql,分组后,再次进行过滤
查出平均分大于80以上的班级 select class_id, avg(score) from students group by class_id having avg(score)>80; ...
- poj 2505 乘法博弈论
转自:http://hzwer.com/1921.html 题目大意: 题意:Stan从1开始,可以乘上2~9中任何一个数,Ollie也如此操作,只到某个人本回合的操作超过N为之..1<N< ...
- ubuntu chm文档阅读器
一,chm阅读器名称 KchmViewer 安装方法 sudo apt-get install kchmviewer 使用 kchmviewer #非root用户可以直接使用