public void ConvertExcelToCSV_with_no_file() { ConvertExcel test = new ConvertExcel(); Assert.Throws <ArgumentException>(() => test.ConvertExcelToCsv(" ", " ", 5)); Assert.Throws <ArgumentException>(() => test.ConvertExcelToCsv(string.Empty, string.Empty, 2)); Assert.Throws <FileNotFoundException>(() => test.ConvertExcelToCsv("argeuh.xlp", "not null", 2)); }
public Subset ConvertExcel() { ConvertExcel test = new ConvertExcel(); Subset poigneegaz = new Subset(); OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string excelPath = openFileDialog1.FileName; string CSVPath = excelPath; CSVPath = CSVPath.Remove(CSVPath.Length - 4, 4) + "csv"; test.ConvertExcelToCsv(excelPath, CSVPath, 1); poigneegaz = test.GetDataTableFromCsv(CSVPath); } return(poigneegaz); }
public static int importRatesTemplate(string _file, string _year) { DataSet impData = new DataSet(); DataTable dt = new DataTable("rateTemplate"); if (_file.Contains(_year)) { try { impData.Tables.Add(ConvertExcel.ConvertXLS(_file, dt)); int _cnt = IPBAImportDAL.insertRates(impData); return(_cnt); } catch (Exception ex) { throw ex;; } } else { throw (new Exception("Selected file is not for year - '" + _year + "'. Please import correct file.")); } }
public void Subset_infos_are_well_calculated() { ConvertExcel test = new ConvertExcel(); Subset poigneegaz = new Subset(); string excelPath = @"D:\Dev\S5\Projet C#\Excel pour PlaneConstructor\poigneegaz.xlsx"; string CSVPath = excelPath; CSVPath = CSVPath.Remove(CSVPath.Length - 4, 4) + "csv"; test.ConvertExcelToCsv(excelPath, CSVPath, 1); poigneegaz = test.GetDataTableFromCsv(CSVPath); int result1 = poigneegaz.GetTheLongestDOSub(); // TODO pb de double double result2 = poigneegaz.GetTotalCostSub(); int result3 = poigneegaz.GetTotalHourSub(); int result4 = poigneegaz.GetMaxLevel(); Assert.That(result1, Is.EqualTo(752)); Assert.That(result2, Is.EqualTo(60598.25d)); Assert.That(result3, Is.EqualTo(406)); Assert.That(result4, Is.EqualTo(7)); }