0

我正在尝试将 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 文件。

我的问题是如何导出格式化文本?

4

1 回答 1

0

你为什么要编码它?

将“测试用例提取器”下载到 Excel 并将所有测试用例导出到 Excel 工作表。

于 2013-01-15T07:40:06.240 回答