我正在尝试将TFS 2012测试用例导出为excel。 目前我能够使用以下代码
将数据导出为excel作为纯文本 foreach (ITestCase Testcase in testcases)
{
int j = 1;
string str1 = null;
string str2 = null;
foreach (ITestAction action in Testcase.Actions)
{
ISharedStep shared_step = null;
ISharedStepReference shared_ref = action as ISharedStepReference;
if (shared_ref != null)
{
shared_step = shared_ref.FindSharedStep();
foreach (ITestAction shr_action in shared_step.Actions)
{
var test_step = shr_action as ITestStep;
str1 = str1 + j.ToString() + "." + ((test_step.Title.ToString().Length ==0)? "<<Not Recorded>>" : test_step.Title.ToPlainText()) + System.Environment.NewLine;
str2 = str2 + j.ToString() + "." + ((test_step.ExpectedResult.ToString().Length ==0) ? "<<Not Recorded>>" : test_step.ExpectedResult.ToPlainText()) + System.Environment.NewLine;
j++;
}
}
else
{
var test_step = action as ITestStep;
str1 = str1 + j.ToString() + "." + ((test_step.Title.ToString().Length ==0) ? "<<Not Recorded>>" : test_step.Title.ToPlainText()) + System.Environment.NewLine;
str2 = str2 + j.ToString() + "." + ((test_step.ExpectedResult.ToString().Length ==0) ? "<<Not Recorded>>" : test_step.ExpectedResult.ToPlainText()) + System.Environment.NewLine;
j++;
}
}
oSheet.Cells[i, 1].Value = Testcase.Id.ToString();
oSheet.Cells[i, 2].Value = Testcase.Title.ToString();
oSheet.Cells[i, 3].Value = str1;
oSheet.Cells[i, 4].Value = str2;
ParameterizedString Description = Testcase.Description;
oSheet.Cells[i, 5].Value = Description.ToPlainText();
i++;
}
我正在使用EPPlus.dll写入excel文件。
我的问题是如何导出格式化文本?
答案 0 :(得分:0)
为什么要尝试编码?
将“测试用例提取器”下载到excel并将所有测试用例导出到Excel工作表。