C#:DataTable内容转换为String(XML)
//DataTable转String方法
public static String DataTable2String(DataTable dt)
{
string strXML = "<DataTable>\r\n";
try
{
foreach (DataRow dr in dt.Rows)
{
strXML += "<Row>\r\n";
foreach (DataColumn dc in dt.Columns)
{
strXML += string.Format("<Column name='{0}' value='{1}'>\r\n", dc.ColumnName, dr[dc.ColumnName]);
}
strXML += "</Row>\r\n";
}
}
catch (Exception e)
{
strXML += string.Format("DataTable2String异常:" + e.Message);
}
strXML += "</DataTable>";
return strXML;
}
C#:DataTable内容转换为String(XML)的更多相关文章
- 将XML文件中的内容转换为Json对象
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Xml;u ...
- 将PPT文件内容转换为图片放在Email邮件正文中发送
通过Email推送统计报告.一般除了要求将PPT报告文件作为附件发给用户,同时希望将报告内容在邮件中直观展示. 一份统计报告中经常包含柱状图.饼图.好看的图表,这些信息要直接在Email中展示比较复杂 ...
- C# 实现DataTable、DataSet与XML互相转换
/**//// <summary> /// 把DataSet.DataTable.DataView格式转换成XML字符串.XML文件 /// </summary> public ...
- android中string.xml中%1$s、%1$d等的用法
今天在研究前辈写的代码的时候,突然发现string里面出现了<stringname="item_recent_photo">最近拍摄%1$s</string> ...
- Android中string.xml文件中设置部分字体颜色大小
1.在string.xml文件中: <string name="tips_all"><Data><![CDATA[清理进程:<font colo ...
- 你所不知道的string.xml
String 能被应用程序或者其他资源文件(比如layout XML)引用的单个字符串. 注意:字符串是简单类型资源,是用名称(name)(而非XML文件名)来直接引用的.因此,在一个XML文件里,可 ...
- DataTable 对象 转换为Json 字符串
/// <summary> /// DataTable 对象 转换为Json 字符串 /// </summary> /// <param name="dt&qu ...
- 将DataTable内容导出到Excel表格的两种方法
方法一:循环DataTable单元格内容拼接字符串,利用StreamWriter的Write方法将字符串写入Excel文件中 这种方法很实现很简单.拼接字符串时,每个单元格之间添加'\t'(表示一个占 ...
- 读取Excel列,转换为String输出(Java实现)
需要导入的jar包 具体实现 public class ColumnToString { public static void main(String[] args) { new ColumnToSt ...
随机推荐
- python eval
缘起 小例子 def test_1(val): print "val", val, type(val) def test_2(val): print ) if __name__ = ...
- Spring Security HTTP Basic for RESTFul and FormLogin (Cookies) for web - Annotations
@Configuration @EnableWebMvcSecurity @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabl ...
- 第8章 委托、Lamdba表达式和事件
本章内容: 委托 Lambda表达式 事件 8.1.3 简单的委托示例 首先定义一个类MathOperations,它有两个静态方法,对double类型的值执行两个操作. public cl ...
- 浅谈C#抽象方法、虚方法、接口
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客!当然,希望将来的一天,某位老板看到此博客,给你的程序员职工加点薪资吧!因为程序员的世界除了苦逼就是沉默.我眼中的程序员大多都不 ...
- mysql:批量更新
(优化前)一般使用的批量更新的方法: foreach ($display_order as $id => $ordinal) { $sql = "UPDATE categori ...
- PAT 解题报告 1004. Counting Leaves (30)
1004. Counting Leaves (30) A family hierarchy is usually presented by a pedigree tree. Your job is t ...
- HTML语言的一些元素(三)
本章节主要介绍:<div>和<span> 可以通过 <div> 和 <span> 将 HTML 元素组合起来. HTML <div> 元素是 ...
- Leetcode: Shuffle an Array
Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] n ...
- F面经:painting house
There are a row of houses, each house can be painted with three colors red, blue and green. The cost ...
- Android Studio更新升级方法(转)
自从2013 Google I/O大会之后,笔者就将android ide开发工具从eclipse迁移到Android Studio了,android studio一直在更新完善,为了与时俱进,我们当 ...