C#实现将Excel测试用例转换成Testlink支持的xml方便导入
来源:互联网 发布:如龙 淘宝暗号 编辑:程序博客网 时间:2024/05/22 12:23
资源链接:http://download.csdn.net/detail/w565911788/4325414
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Data.OleDb;using System.IO;namespace ExcelToXml{ class Program { /// <summary> /// 返回Excel数据源 /// </summary> /// <param name="filename">文件路径</param> /// <returns></returns> static public DataTable ExcelToDataSet(string filename) { DataTable ds; string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Extended Properties=Excel 8.0;" + "data source=" + filename; OleDbConnection myConn = new OleDbConnection(strCon); string strCom = " SELECT * FROM [Sheet1$]"; myConn.Open(); OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn); ds = new DataTable(); myCommand.Fill(ds); myConn.Close(); return ds; } static void Main(string[] args) { string filePath = @"F:\TDDOWNLOAD\TestlinkConvert_V67_20120317_TY\test-json-api-success-report.xls"; FileInfo fi = new FileInfo(filePath); string xmlPath = @"D:\" + fi.Name.Replace(".xlsx", "").Replace(".xls", "")+".xml"; FileInfo xmlFi = new FileInfo(xmlPath); FileStream fs = xmlFi.Open(FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); StreamWriter sw= new StreamWriter(fs); string content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testcases>\n"; sw.WriteLine(content); DataTable dt = ExcelToDataSet(filePath); if (dt.Rows.Count > 1) { for (int i = 0; i < dt.Rows.Count-1; i+=2) { content = ""; content += "<testcase name=\""+dt.Rows[i][0].ToString()+"\">"; content += "<summary><![CDATA[" + dt.Rows[i][1].ToString() + @"]]></summary><preconditions><![CDATA[correct token: ae873897a0a9a2afdb676eefe4e864e2b0e3abb07cd73cf0944e77d6c792b1aa7926f07dd201b6aa<br />]]></preconditions> <execution_type><![CDATA[0]]></execution_type><importance><![CDATA[0]]></importance><steps>"; content += "<step><step_number><![CDATA[1]]></step_number><actions><![CDATA[" + dt.Rows[i][2].ToString() + "]]></actions>"; content += "<expectedresults><![CDATA[" + dt.Rows[i][3].ToString() + "]]></expectedresults><execution_type><![CDATA[1]]></execution_type></step>"; content += "<step><step_number><![CDATA[2]]></step_number><actions><![CDATA[" + dt.Rows[i+1][2].ToString() + "]]></actions>"; content += "<expectedresults><![CDATA[" + dt.Rows[i+1][3].ToString() + "]]></expectedresults><execution_type><![CDATA[1]]></execution_type></step>"; content += "</steps></testcase>"; sw.WriteLine(content); } } sw.WriteLine("</testcases>\n"); sw.Close(); fs.Close(); } }}
- C#实现将Excel测试用例转换成Testlink支持的xml方便导入
- Excel中任意格式用例转成testlink支持导入的xml格式
- TestLink学习七:TestLink测试用例Excel转换XML工具
- Excel中测试用例导入Testlink方法
- 将testlink导出的xml格式用例转化为Excel
- Testlink用例转换工具(excel转为xml,python版)
- testlink测试用例导出xml,转为Excel格式(python)
- c#将Excel数据导入到数据库的实现代码
- c# 实现将Excel导入到dataGridView
- Excel导入TestLink
- c# 将xml格式的Excel文件转换为标准的Excel
- testlink xml转excel
- TestLink1.9.3测试用例:Excel转换XML工具<二>实现代码
- 把Testlink的case导出转成excel,或把excel导入Testlink
- 技巧: 将 Excel 数据转换成 XML
- poi将excel转换成list集合,excel导入
- C#实现将DataGridView中的数据导入到Excel中
- TestLink-之如何使用Excell导入测试用例与测试用例集
- JavaScript等比例缩放图片
- 基于模式的架构评审
- 程序员最爱的书籍汇总
- Serial ATA (SATA) chipsets — Linux support status
- jQuery RadioButton、input、CheckBox取值赋值
- C#实现将Excel测试用例转换成Testlink支持的xml方便导入
- windows [git] warning: LF will be replaced by CRLF
- C语言编译器MINGW的使用说明
- php获取文件扩展名的几种方法
- 奉上百度网盘邀请码8枚~先到先得哈!百度出品哈!
- 坐标系、坐标参照系、坐标变换、投影变换
- rfkill - RF kill switch support (翻译)
- 大梦谁先觉 --伍立杨
- C语言转义字符