我正在创建一个控制台应用程序,该应用程序从Excel文件中随机选择问题和答案。以下是我的代码(一点都不完整)。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Excel = Microsoft.Office.Interop.Excel;
namespace QuizMaker
{
class Program
{
static void Main(string[] args)
{
int numCorrectA;
int numTotalQ;
decimal score;
List<string> qArray = new List<string>();
List<string> aArray = new List<string>();
Excel.Application xlApp = new Excel.Application();
Excel.Workbook quizWorkbook = new xlApp.Workbooks.Open("-file location-");
//read random line from excel file for 6 questions
//print out questions
//console.readline() for the answers
//check answers b ycomparing them
//increment ints as needed
//output results
}
}
}
因此,我是xlApp通过调用Application接口创建的,但是当我xlApp在下面的行中使用时,遇到了“是变量,但像类型一样使用”错误。在查找之后,接口似乎没有创建实例,所以这就是原因。但是,我试图创建另一个类来实现Excel.Application,但这是行不通的。我不知道要创建新的应用程序还需要做什么。
天涯尽头无女友
凤凰求蛊
慕哥6287543
相关分类