lib/roo/generic_spreadsheet.rb in roo-1.9.7 vs lib/roo/generic_spreadsheet.rb in roo-1.10.0
- old
+ new
@@ -30,11 +30,28 @@
def self.next_tmpdir
tmpdir = "oo_"+$$.to_s+"_"+sprintf("%010d",rand(10_000_000_000))
tmpdir
end
+ def self.split_coordinate(str)
+ letter,number = GenericSpreadsheet.split_coord(str)
+ x = letter_to_number(letter)
+ y = number
+ return y, x
+ end
+ def self.split_coord(s)
+ if s =~ /([a-zA-Z]+)([0-9]+)/
+ letter = $1
+ number = $2.to_i
+ else
+ raise ArgumentError
+ end
+ return letter, number
+ end
+
+
public
# sets the working sheet in the document
# 'sheet' can be a number (1 = first sheet) or the name of a sheet.
def default_sheet=(sheet)
@@ -330,13 +347,10 @@
ds = @default_sheet
if self.class.to_s == 'Google'
initialize(@spreadsheetkey,@user,@password)
else
initialize(@filename)
- to do
- 'was ist mit weiteren Parametern bei initialize'
- end
end
self.default_sheet = ds
#@first_row = @last_row = @first_column = @last_column = nil
end
@@ -426,10 +440,12 @@
else
super
end
end
+=begin
+#TODO: hier entfernen
# returns each formula in the selected sheet as an array of elements
# [row, col, formula]
def formulas(sheet=nil)
theformulas = Array.new
sheet = @default_sheet unless sheet
@@ -443,27 +459,29 @@
end
}
}
theformulas
end
+=end
protected
def file_type_check(filename, ext, name, packed=nil)
new_expression = {
'.ods' => 'Openoffice.new',
'.xls' => 'Excel.new',
'.xlsx' => 'Excelx.new',
+ '.csv' => 'Csv.new',
}
if packed == :zip
# lalala.ods.zip => lalala.ods
# hier wird KEIN unzip gemacht, sondern nur der Name der Datei
# getestet, falls es eine gepackte Datei ist.
filename = File.basename(filename,File.extname(filename))
end
case ext
- when '.ods', '.xls', '.xlsx'
+ when '.ods', '.xls', '.xlsx', '.csv'
correct_class = "use #{new_expression[ext]} to handle #{ext} spreadsheet files"
else
raise "unknown file type: #{ext}"
end
if File.extname(filename).downcase != ext
@@ -676,6 +694,7 @@
m = (content/60.0).floor
content = content - m*60
s = content
sprintf("%02d:%02d:%02d",h,m,s)
end
+
end