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 ...
随机推荐
- 分布式ID增强篇--优化时钟回拨问题
原生实现 本文承接sharding-jdbc源码之分布式ID,在这篇文章中详细介绍了sharding-jdbc的分布式ID是如何实现的:很遗憾的是sharding-jdbc只是基于snowflake算 ...
- highcharts.js两种数据绑定方式和异步加载数据的使用
一,我们先来看看异步加载数据的写法(这是使用MVC的例子) 1>js写法 <script src="~/Scripts/jquery-2.1.4.min.js"> ...
- 【记录】mysql查询语句对于为null和为空字符串给出特定值处理
SELECT if(IFNULL(filedName,"指定字符串")="","指定字符串",filedName) '重命名的字符名' FR ...
- REINDEX - 重建索引
SYNOPSIS REINDEX { DATABASE | TABLE | INDEX } name [ FORCE ] DESCRIPTION 描述 REINDEX 基于存储在表上的数据重建索引, ...
- 233-基于TMS320C6678+XC7K325T的CPCIe开发平台
基于TMS320C6678+XC7K325T的CPCIe开发平台 一.板卡概述 该DSP+FPGA高速信号采集处理板由我公司自主研发,包含一片TI DSP TMS320C6678和一片 ...
- Vue 侦听属性
Vue 提供了一种更通用的方式来观察和响应 Vue 实例上的数据变动:侦听属性 <!DOCTYPE html> <html> <head> <meta cha ...
- elasticsearch相关聚合查询示例
索引(index):logstash-nginx-*,type:nginx_access 请求路径: 1.按照某个字段进行分组统计访问量 { "query": { "bo ...
- 前端每日实战:72# 视频演示如何用纯 CSS 创作气泡填色的按钮特效
效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/eKqZjy 可交互视频 此视频是可 ...
- Linux下安装gnuplot
sudo apt-get install gnuplot 但是在 terminal 里面输入: gnuplot 提示 Terminal type set to unknown.解决方法是安装 x11: ...
- Web核心之Request对象
HTTP协议中Request请求部分格式 //请求行(这种是POST类型的请求) POST /HttpServleLogin.html HTTP/1.1 //请求头(User-Agent里有Firef ...