Dictionary<int, string> dict = new Dictionary<int, string>();
List<string> list = new List<string>();
object missing = Missing.Value;
Application excel = new Application();
excel.Visible = false;
excel.UserControl = true;
Workbook book = excel.Application.Workbooks.Open(file, missing, false,
missing, missing, missing, missing, missing, missing, true,
missing, missing, missing, missing, missing);
Worksheet sheet = (Worksheet)book.Worksheets.get_Item(4);
int rowCount = sheet.UsedRange.Cells.Rows.Count;
int success = 0;
for (int i = 2; i < rowCount; i++)
{
Range r1 = sheet.Cells.get_Range(string.Format("Q{0}", i), missing);
object isOffline = r1.Value;
if (isOffline != null && (isOffline.ToString() == "是" || isOffline.ToString() == "?"))
{
Range r2 = sheet.Cells.get_Range(string.Format("A{0}", i), missing);
object obj = r2.Value;
string value = obj == null ? "" : obj.ToString();
dict.Add(i, value);
if (!value.Contains("@"))
{
list.Add(value);
}
if (value != "")
{
BsDicFormVersion model = models.FirstOrDefault(a => a.Version_Name == value);
if (model != null)
{
sheet.Cells[i, 19] = model.Version_Name;
sheet.Cells[i, 20] = model.Form_Version;
sheet.Cells[i, 21] = model.Template_File_Path;
sheet.Cells[i, 22] = model.Input_Type;
sheet.Cells[i, 23] = model.Jsp_Path;
sheet.Cells[i, 24] = model.Open_Kind;
success++;
}
}
}
}
Console.WriteLine(success);
sheet.SaveAs("D:\\15.xlsx");
book.Close();
excel.Quit();