Module: Poi2csv
- Defined in:
- lib/poi2csv.rb,
lib/poi2csv/version.rb
Constant Summary collapse
- Poi2csvException =
Class.new(StandardError)
- SUPPORTED_EXTENSIONS =
['xls', 'xlsx']
- VERSION =
"0.0.5.2"
Class Method Summary collapse
- .classpath ⇒ Object
- .output_file_created?(input_file_path, output_folder_path) ⇒ Boolean
- .supports_extension?(extension) ⇒ Boolean
- .to_csv(input_file_path, output_folder_path, separator = nil, formating_convention = nil) ⇒ Object
Class Method Details
.classpath ⇒ Object
20 21 22 |
# File 'lib/poi2csv.rb', line 20 def self.classpath @_classpath ||= File.(File.join(File.dirname(__FILE__),'*')) + File::PATH_SEPARATOR + File.(File.join(File.dirname(__FILE__),'..', 'classes')) end |
.output_file_created?(input_file_path, output_folder_path) ⇒ Boolean
24 25 26 27 |
# File 'lib/poi2csv.rb', line 24 def self.output_file_created?(input_file_path, output_folder_path) output_file = File.join(output_folder_path , File.basename(input_file_path, '.*')) + '.csv' File.exists?(output_file) end |
.supports_extension?(extension) ⇒ Boolean
16 17 18 |
# File 'lib/poi2csv.rb', line 16 def self.supports_extension?(extension) SUPPORTED_EXTENSIONS.include?(extension) end |
.to_csv(input_file_path, output_folder_path, separator = nil, formating_convention = nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/poi2csv.rb', line 9 def self.to_csv(input_file_path, output_folder_path, separator=nil, formating_convention=nil) args = [input_file_path, output_folder_path, separator, formating_convention].reject { |v| v.nil? } args = args.map { |v| Shellwords.escape(v) } = `java -cp #{classpath} ToCSV #{args * ' '}` raise Poi2csvException.new, unless output_file_created?(input_file_path, output_folder_path) end |