一、编程思想
跟上一篇类似的思想,只是这次多利用了C#中几个好用的字符串函数string.indexof()和string.substring()
二、程序运行后导入Excel
即把用逗号分列好的目标文本.txt导入Excel文件中,我并没有直接对Excel进行读写,这点读者必须注意。达到了我们编程的目的就可以了。截图如下:
三、主要代码
这次的代码比较多,因为涉及几个题型,有单选题和多选题,这里为了简化,只贴出读取单选题的函数代码。重复的代码也比较多的,因为处理的步骤都类似。
static void processTextSingle(string text)
{
int questionNum = scanQuestionNum(text);
string targetText = "题目,选项一,选项二,选项三,选项四,答案\n";
string toFindTextSingle = "单项选择题";
string toFindTextMulti = "多项选择题";
string tempText = text.Substring(0, text.Length);
string[] tempQText = new string[questionNum];
string[] tempAText = new string[questionNum];
string[] tempBText = new string[questionNum];
string[] tempCText = new string[questionNum];
string[