public ExcelImportResult Process(
            BackgroundWorker bw)
        {
            using (var tfc = new TemporaryFileCloner(_information.SourceFilePath))
            {
                var dataSet = CoreExcelImporter.ImportExcelFromFile(tfc.FilePath);

                var result = new ExcelImportResult();

                var tableIndex = 0;
                foreach (DataTable table in dataSet.Tables)
                {
                    if (bw.CancellationPending)
                    {
                        throw new OperationCanceledException();
                    }

                    processTableFileIntelligent(
                        result,
                        tableIndex,
                        dataSet,
                        table,
                        bw);

                    tableIndex++;
                }

                return(result);
            }
        }
 public static string[] DetectLanguagesFromExcelFile(
     string filePath)
 {
     if (string.IsNullOrEmpty(filePath) ||
         StringExtensionMethods.ToLowerInvariantIntelligent(ZlpPathHelper.GetExtension(filePath)) != @".xlsx" ||
         !ZlpIOHelper.FileExists(filePath))
     {
         return(null);
     }
     else
     {
         using var tfc = new TemporaryFileCloner(filePath);
         var wb = CoreExcelImporter.ImportExcelFromFile(tfc.FilePath);
         return(detectLanguagesFromWorkbook(wb));
     }
 }
Ejemplo n.º 3
0
        public static FileGroup[] DetectFileGroupsFromExcelFile(
            Project project,
            string filePath)
        {
            if (string.IsNullOrEmpty(filePath) ||
                (
                    StringExtensionMethods.ToLowerInvariantIntelligent(ZlpPathHelper.GetExtension(filePath)) != @".xlsx"
                )
                ||
                !ZlpIOHelper.FileExists(filePath))
            {
                return(null);
            }
            else
            {
                using (var tfc = new TemporaryFileCloner(filePath))
                {
                    var ds = CoreExcelImporter.ImportExcelFromFile(tfc.FilePath);

                    return(detectFileGroupsFromWorkbook(project, ds));
                }
            }
        }