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));
     }
 }
 public static string[] DetectLanguagesFromExcelFile(
     string filePath)
 {
     if (string.IsNullOrEmpty(filePath) ||
         (
         StringExtensionMethods.ToLowerInvariantIntelligent(ZlpPathHelper.GetExtension(filePath)) != @".xls" &&
         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);
         }
     }
 }
示例#4
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));
                }
            }
        }
        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;
            }
        }