private void AddToExcel(string[,] texts, string excelPath, string excelName) { ExcelClass xls = new ExcelClass(); try { xls.NewDocument(); string fullPath = Path.Combine(excelPath, excelName); xls.SaveDocument(fullPath); xls.OpenDocument(fullPath, false); for (int i = 0; i < texts.GetLength(0); i++) { for (int j = 0; j < texts.GetLength(1); j++) { xls.SetCellValue(j + 1, i + 1, texts[i, j].Trim()); } } xls.SetAutoFit("B:B"); xls.SetAutoFit("C:C"); xls.SetAutoFit("D:D"); xls.SetAutoFit("E:E"); xls.SetAutoFit("F:F"); } finally { xls.CloseDocumentSave(); xls.Dispose(); } }