# Copyright (C) 2005 Network Applied Communication Laboratory Co., Ltd. # # This file is part of Rast. # See the file COPYING for redistribution information. # require File.join(File.dirname(__FILE__), "read-buckets-to-file") require File.join(File.dirname(__FILE__), "msoffice-property") class ApplicationExcel SUPPORTED_VERSION = 1 MIME_TYPE = "application/vnd.ms-excel" EXTENSIONS = ["xls"] include ReadBucketsToFile include MSOfficeProperty private def process_file(filter, mime_type, path) s = "" IO.popen("xlhtml #{path}") do |io| s = io.read end if !$?.success? && s.empty? raise Rast::RastError.new("failed to convert file") end bucket = Rast::TransientBucket.new(s) next_brigade = Rast::Brigade.new next_brigade.insert_tail(bucket) next_brigade.insert_tail(Rast::EOSBucket.new) filter.pass(next_brigade, "text/html") extract_property(filter, mime_type, path) end end