1 31 32 package org.opencms.search.documents; 33 34 import org.opencms.file.CmsFile; 35 import org.opencms.file.CmsObject; 36 import org.opencms.file.CmsResource; 37 import org.opencms.main.CmsException; 38 import org.opencms.search.A_CmsIndexResource; 39 import org.opencms.search.CmsIndexException; 40 import org.opencms.search.extractors.CmsExtractorMsExcel; 41 import org.opencms.search.extractors.I_CmsExtractionResult; 42 43 import java.io.FileNotFoundException ; 44 45 55 public class CmsDocumentMsExcel extends A_CmsVfsDocument { 56 57 62 public CmsDocumentMsExcel(String name) { 63 64 super(name); 65 } 66 67 72 public I_CmsExtractionResult extractContent(CmsObject cms, A_CmsIndexResource indexResource, String language) 73 throws CmsIndexException, CmsException { 74 75 CmsResource resource = (CmsResource)indexResource.getData(); 76 CmsFile file = readFile(cms, resource); 77 78 try { 79 return CmsExtractorMsExcel.getExtractor().extractText(file.getContents()); 80 } catch (Exception e) { 81 if (e instanceof FileNotFoundException ) { 82 if (e.getMessage() != null && e.getMessage().indexOf("Workbook") > 0) { 83 throw new CmsIndexException(Messages.get().container( 85 Messages.ERR_NO_EXCEL_FORMAT_1, 86 resource.getRootPath()), e); 87 } 88 } 89 throw new CmsIndexException( 90 Messages.get().container(Messages.ERR_TEXT_EXTRACTION_1, resource.getRootPath()), 91 e); 92 } 93 } 94 } | Popular Tags |