0
我想將TFS 2012測試用例導出爲excel。 目前我能夠將數據導出用下面的代碼從TFS導出豐富的文本格式到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文件擅長爲純文本。
我的問題是如何導出格式化文本?
測試用例提取器僅支持TFS 2010,此代碼支持與TFS 2010中功能相同的tfs 2012. 但我想導出富文本而不僅僅是純文本。 – ekrako
哦.......你可以看到「shai raiton」forams。 –
友善地爲谷歌爲shai raiton崗位..他是mvp並且爲TFS做了幾件事2012年。也許是您能問他或得到他的articals的任何幫助 –