Esempio n. 1
0
        public string parseFiles(string strDirectory, string[] fileNames)
        {
            // we only want the month and year from the file name
            string[] strName   = fileNames[0].Split(' ').Where((x, index) => index != 2).ToArray();
            string   strWBName = string.Join("", strName) + ".xlsx";

            XLWorkbook xlWB = new XLWorkbook();

            for (int j = 0; j < fileNames.Length; j++)
            {
                string shtName = fileNames[j].Replace(".txt", "");
                if (shtName.Length > 30)
                {
                    clsUnZip objUnzip = new clsUnZip();
                    shtName = objUnzip.RenameFile(shtName);
                }
                IXLWorksheet xlSht = xlWB.Worksheets.Add(shtName);
                int          iRow  = 2;
                iRow = streamFile(ref iRow, strDirectory, fileNames[j], ref xlSht, "C");


                addFormulas(xlSht, iRow, iRow + 2, "Debit");
                addFormulas(xlSht, iRow, iRow + 3, "Credit");

                addFormulas(xlSht, iRow, iRow + 5, "Grand Total");

                formatSheet(xlSht, iRow + 5);
            }

            string strFile = strDirectory + "//" + strWBName;

            xlWB.SaveAs(strFile);
            return(strFile);
        }
Esempio n. 2
0
 private void UnzipFiles(string strPath)
 {
     string[] FileNames;
     string[] filePaths = Directory.GetFiles(strPath, "*.zip");
     if (filePaths.Count() == 0)
     {
         MessageBox.Show("There were no zip files in the directory selected, please navigate to the appropriate directory");
     }
     else
     {
         clsUnZip objUnZip = new clsUnZip();
         FileNames = objUnZip.UnzipFiles(strPath, filePaths);
         if (FileNames.Length > 0)
         {
             strXL            = parseFiles(strPath, FileNames);
             butExcel.Enabled = true;
             lblStatus.Text   = "";
         }
         else
         {
             MessageBox.Show("The files did not unzip properly. Try again, if the problem persists contact IT.");
         }
     }
 }