private void save_btn_Click(object sender, RoutedEventArgs e) { ProcessExcel.SaveToCell(openFileDialog.FileName, dict["Row"], dict["Column"], NumbersToText.ConvertAmountInPLN(ProcessExcel.ReadCellValue(openFileDialog.FileName, dict["Row"], dict["Column"]))); save_btn.IsEnabled = false; if (openAfterSave_chkbox.IsChecked == true) { System.Diagnostics.Process.Start(openFileDialog.FileName); } }
public void TestUnexistingFolder() { string unexistedFolder; do { unexistedFolder = "E:\\" + DateTime.Now.Ticks.ToString(); } while (Directory.Exists(unexistedFolder)); bool wasCreated = ProcessExcel.TryCreateCsv(Path.Combine(Environment.CurrentDirectory, "TestData", "TestExcel2003.xls"), unexistedFolder + "\\"); Assert.AreEqual(wasCreated, false); }
/// <summary> /// Internal method to process excel file with expected worksheets /// </summary> /// <param name="fileName">fileName (note that this file should be placed in TestData folder</param> /// <param name="expectedCorrectWorksheets">the expected count of correct worksheets</param> /// <param name="isExpectedCorrectWorkbook">do we expect that workbook at filename is correct</param> private void TestTryProcessing(string fileName, int expectedCorrectWorksheets, bool isExpectedCorrectWorkbook) { IProcessWorkbookResult resultProcessing; bool wasFileProcessed = ProcessExcel.TryProcessWorkbook(Path.Combine(Environment.CurrentDirectory, "TestData", fileName), out resultProcessing); Assert.AreEqual(wasFileProcessed, isExpectedCorrectWorkbook); if (wasFileProcessed) { Assert.AreEqual(expectedCorrectWorksheets, resultProcessing.SheetToCsvModels.Count); } }
/// <summary> /// Internal method to process excel file with expected worksheets /// </summary> /// <param name="fileName">fileName (note that this file should be placed in TestData folder</param> /// <param name="expectedCsvFiles">the expected count of correct worksheets</param> private void TestCreateCsv(string fileName, int expectedCsvFiles) { string nameForOutputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", DateTime.Now.Ticks.ToString()); Directory.CreateDirectory(nameForOutputDirectory); // create directory for output csv ProcessExcel.CreateCsv(Path.Combine(Environment.CurrentDirectory, "TestData", fileName), nameForOutputDirectory + "\\"); var filesCollection = Directory.GetFiles(nameForOutputDirectory, "*.csv"); Directory.Delete(nameForOutputDirectory, true); // delete temp data (NOTE, we do this before Assert to avoid dirty folders) Assert.AreEqual(expectedCsvFiles, filesCollection.Length); // it should be expectedCsvFiles count of csv files }
private static void Main(string[] args) { string error; if (CheckArgs(args, out error)) { ProcessExcel.CreateCsv(args[0], args[1]); } else { Console.WriteLine(error); Console.WriteLine("Error have been occured while processing "); } }
/// <summary> /// Test that we'll correctly process situation when we try to write in unexisting folder /// </summary> ////[TestMethod] public void TestUnexistingFolder() { try { string unexistedFolder; do { unexistedFolder = "E:\\" + DateTime.Now.Ticks.ToString(); } while (Directory.Exists(unexistedFolder)); ProcessExcel.CreateCsv(Path.Combine(Environment.CurrentDirectory, "TestData", "TestExcel2003.xls"), unexistedFolder + "\\"); } catch (DirectoryNotFoundException) { //good exception } }
/// <summary> /// Internal method to process excel file with expected worksheets /// </summary> /// <param name="fileName">fileName (note that this file should be placed in TestData folder</param> /// <param name="expectedCsvFiles">the expected count of correct worksheets</param> /// <param name="isExpectedCorrectWorkbook">do we expect that workbook at filename is correct</param> private void TestTryCreateCsv(string fileName, int expectedCsvFiles, bool isExpectedCorrectWorkbook) { string nameForOutputDirectory = Path.Combine(Environment.CurrentDirectory, "TestData", DateTime.Now.Ticks.ToString()); Directory.CreateDirectory(nameForOutputDirectory); // create directory for output csv IProcessWorkbookResult resultProcessing; var wasFileProcessed = ProcessExcel.TryCreateCsv(Path.Combine(Environment.CurrentDirectory, "TestData", fileName), nameForOutputDirectory + "\\"); var filesCollection = Directory.GetFiles(nameForOutputDirectory, "*.csv"); Directory.Delete(nameForOutputDirectory, true); // delete temp data (NOTE, we do this before Assert to avoid dirty folders) Assert.AreEqual(wasFileProcessed, isExpectedCorrectWorkbook); if (wasFileProcessed) { Assert.AreEqual(expectedCsvFiles, filesCollection.Length); } }
private void button_Click(object sender, RoutedEventArgs e) { try { dict = ProcessExcel.ReadCellFromTxt(); if (openFileDialog.ShowDialog() == true) { file_txtbox.Text = openFileDialog.FileName; } currentValue_txtbox.Text = ProcessExcel.ReadCellValue(openFileDialog.FileName, dict["Row"], dict["Column"]); valueToSave_txtbox.Text = NumbersToText.ConvertAmountInPLN(ProcessExcel.ReadCellValue(openFileDialog.FileName, dict["Row"], dict["Column"])); save_btn.IsEnabled = true; } catch (Exception ex) { currentValue_txtbox.Text = "Błąd! " + ex.Message; valueToSave_txtbox.Text = "Błąd! " + ex.Message; save_btn.IsEnabled = false; } }
/// <summary> /// Internal method to process excel file with expected worksheets /// </summary> /// <param name="fileName">fileName (note that this file should be placed in TestData folder</param> /// <param name="expectedCorrectWorksheets">the expected count of correct worksheets</param> private void TestProcessing(string fileName, int expectedCorrectWorksheets) { var resultProcessing = ProcessExcel.ProcessWorkbook(Path.Combine(Environment.CurrentDirectory, "TestData", fileName)); Assert.AreEqual(expectedCorrectWorksheets, resultProcessing.SheetToCsvModels.Count); // it should be expectedCorrectWorksheets count of csv files }