如何使用Microsoft.Office.Interop.Excel从List <string>创buildExcel文件

我有一个值列表,我也有一个文本框,我必须写一个数字,然后我需要build立一个Excel与许多表中的值来自列表。 换句话说,例如:列表有1000个值,然后我在文本框中input100,所以我需要生成一个Excel文件,其中包含很多工作表,因为这些值是在列表中迭代input到文本框中的值一个Excel文件10张,每个工作表100个单元格。 很明显? 我怎样才能使用Microsoft.Office.Interop.Excel做到这一点?

对于工作表:

//get the first workbook in an application Workbook WB = Application.Workbooks[0]; //Or any other workbook you preffer Now loop the following for each list of strings you have (each list to a worksheet) Worksheet WS = (Worksheet)WB.Worksheets.Add(); //this command adds worksheets Range R = WS.Range["A1"]; //or any other cell you like //now for cells for (int i = 0; i < YourStringList.Count; i++) //I believe you can manage to separate the lists yourself { R.Offset[i, 0].Value = YourStringList[i]; } End of the loop