本文整理汇总了C#中ExportFormat.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ExportFormat.ToString方法的具体用法?C# ExportFormat.ToString怎么用?C# ExportFormat.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExportFormat
的用法示例。
在下文中一共展示了ExportFormat.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
/// <summary>
/// 导出SmartGridView的数据源的数据
/// </summary>
/// <param name="ds">数据源</param>
/// <param name="headers">导出的表头数组</param>
/// <param name="fields">导出的字段数组</param>
/// <param name="exportFormat">导出文件的格式</param>
/// <param name="fileName">输出文件名</param>
/// <param name="encoding">编码</param>
/// <param name="function">字段名称 / 函数 对</param>
private static void Export(DataSet ds, string[] headers, string[] fields,
ExportFormat exportFormat, string fileName, Encoding encoding, Dictionary<string, string> function)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = String.Format("text/{0}", exportFormat.ToString().ToLower());
HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment;filename={0}.{1}", fileName, exportFormat.ToString().ToLower()));
HttpContext.Current.Response.ContentEncoding = encoding;
MemoryStream stream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(stream, encoding);
CreateStylesheet(writer, headers, fields, exportFormat, function);
writer.Flush();
stream.Seek(0, SeekOrigin.Begin);
XmlDataDocument xmlDoc = new XmlDataDocument(ds);
XslCompiledTransform xslTran = new XslCompiledTransform();
xslTran.Load(new XmlTextReader(stream));
System.IO.StringWriter sw = new System.IO.StringWriter();
xslTran.Transform(xmlDoc, null, sw);
HttpContext.Current.Response.Write(sw.ToString());
sw.Close();
writer.Close();
stream.Close();
HttpContext.Current.Response.End();
}