Exemplo n.º 1
0
        static IAdapter GetAdapter(string inputFile)
        {
            string extension = Path.GetExtension(inputFile).ToLower();

            switch (extension)
            {
            case ".htm":
            case ".html":
                if (HtmAdapter.CanProcess(inputFile))
                {
                    return(new HtmAdapter(inputFile));
                }
                else
                {
                    return(new AngleHtmlAdapter(inputFile, MaxRowsToProcess));
                }

            case ".pdf":
            case ".xhtml":
            case ".doc":
            case ".rtf":
            case ".toloka_json":
            case ".docx":
                return(GetCommonAdapter(inputFile));

            case ".xls":
            case ".xlsx":
                if (AdapterFamily == "aspose" || AdapterFamily == "prod")
                {
                    if (!AsposeLicense.Licensed && extension == ".xls")
                    {
                        throw new Exception("xls file format is not supported");
                    }

                    if (AsposeLicense.Licensed)
                    {
                        return(AsposeExcelAdapter.CreateAdapter(inputFile, MaxRowsToProcess));
                    }
                }
                else if (AdapterFamily == "npoi")
                {
                    return(NpoiExcelAdapter.CreateAdapter(inputFile, MaxRowsToProcess));
                }
                else
                {
                    return(null);
                }

                break;

            default:
                Logger.Error("Unknown file extension " + extension);
                return(null);
            }

            Logger.Error("Cannot find adapter for " + inputFile);
            return(null);
        }
Exemplo n.º 2
0
        private IAdapter GetAdapter()
        {
            string xlsxFile = Path.Combine(TestUtil.GetTestDataPath(), "Test.xlsx");

            return(NpoiExcelAdapter.CreateAdapter(xlsxFile));
        }