rubyXL 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +9 -9
- data/VERSION +1 -1
- data/lib/worksheet.rb +29 -0
- data/rubyXL.gemspec +1 -1
- data/spec/lib/worksheet_spec.rb +35 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -49,15 +49,15 @@
|
|
49
49
|
workbook[0].get_row_border_right(0) #returns weight of right border of first row (nil if none exists), other directions have the same syntax
|
50
50
|
|
51
51
|
==== Accessing column properties
|
52
|
-
workbook[0].get_column_fill(0) #returns fill color for first column
|
53
|
-
workbook[0].get_column_font_name(0) #returns font name for first column
|
54
|
-
workbook[0].get_column_font_size(0) #returns font size for first column
|
55
|
-
workbook[0].get_column_font_color(0) #returns font color for first column
|
56
|
-
workbook[0].is_column_underlined(0) #returns if first column is italicized, other boolean properties have same syntax
|
57
|
-
workbook[0].get_column_height(0) #returns height of first column
|
58
|
-
workbook[0].get_column_horizontal_alignment(0) #returns horizontal alignment of first column (nil if none exists)
|
59
|
-
workbook[0].get_column_vertical_alignment(0) #returns vertical alignment of first column (nil if none exists)
|
60
|
-
workbook[0].get_column_border_right(0) #returns weight of right border of first column (nil if none exists), other directions have the same syntax
|
52
|
+
workbook[0].get_column_fill(0) #returns fill color for first column
|
53
|
+
workbook[0].get_column_font_name(0) #returns font name for first column
|
54
|
+
workbook[0].get_column_font_size(0) #returns font size for first column
|
55
|
+
workbook[0].get_column_font_color(0) #returns font color for first column
|
56
|
+
workbook[0].is_column_underlined(0) #returns if first column is italicized, other boolean properties have same syntax
|
57
|
+
workbook[0].get_column_height(0) #returns height of first column
|
58
|
+
workbook[0].get_column_horizontal_alignment(0) #returns horizontal alignment of first column (nil if none exists)
|
59
|
+
workbook[0].get_column_vertical_alignment(0) #returns vertical alignment of first column (nil if none exists)
|
60
|
+
workbook[0].get_column_border_right(0) #returns weight of right border of first column (nil if none exists), other directions have the same syntax
|
61
61
|
|
62
62
|
==== Table identification
|
63
63
|
#get table
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.3
|
data/lib/worksheet.rb
CHANGED
@@ -579,6 +579,35 @@ class Worksheet < PrivateClass
|
|
579
579
|
end
|
580
580
|
end
|
581
581
|
|
582
|
+
def insert_cell(row=0,col=0,data=nil,formula=nil,shift=nil)
|
583
|
+
validate_workbook
|
584
|
+
validate_nonnegative(row)
|
585
|
+
validate_nonnegative(col)
|
586
|
+
|
587
|
+
increase_rows(row)
|
588
|
+
increase_columns(col)
|
589
|
+
|
590
|
+
if shift && shift != :right && shift != :down
|
591
|
+
raise 'invalid shift option'
|
592
|
+
end
|
593
|
+
|
594
|
+
if shift == :right
|
595
|
+
@sheet_data[row].insert(col,nil)
|
596
|
+
(row...(@sheet_data[row].size)).each do |index|
|
597
|
+
if @sheet_data[row][index].is_a?(Cell)
|
598
|
+
@sheet_data[row][index].column += 1
|
599
|
+
end
|
600
|
+
end
|
601
|
+
elsif shift == :down
|
602
|
+
@sheet_data << Array.new(@sheet_data[row].size)
|
603
|
+
(@sheet_data.size-1).downto(row+1) do |index|
|
604
|
+
@sheet_data[index][col] = @sheet_data[index-1][col]
|
605
|
+
end
|
606
|
+
end
|
607
|
+
|
608
|
+
return add_cell(row,col,data,formula)
|
609
|
+
end
|
610
|
+
|
582
611
|
# by default, only sets cell to nil
|
583
612
|
# if :left is specified, method will shift row contents to the right of the deleted cell to the left
|
584
613
|
# if :up is specified, method will shift column contents below the deleted cell upward
|
data/rubyXL.gemspec
CHANGED
data/spec/lib/worksheet_spec.rb
CHANGED
@@ -1090,6 +1090,41 @@ describe RubyXL::Worksheet do
|
|
1090
1090
|
end
|
1091
1091
|
end
|
1092
1092
|
|
1093
|
+
describe '.insert_cell' do
|
1094
|
+
it 'should simply add a cell if no shift argument is specified' do
|
1095
|
+
@worksheet.insert_cell(0,0,'test')
|
1096
|
+
@worksheet[0][0].value.should == 'test'
|
1097
|
+
@worksheet[0][1].value.should == '0:1'
|
1098
|
+
@worksheet[1][0].value.should == '1:0'
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
it 'should shift cells to the right if :right is specified' do
|
1102
|
+
@worksheet.insert_cell(0,0,'test',nil,:right)
|
1103
|
+
@worksheet[0][0].value.should == 'test'
|
1104
|
+
@worksheet[0][1].value.should == '0:0'
|
1105
|
+
@worksheet[1][0].value.should == '1:0'
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
it 'should shift cells down if :down is specified' do
|
1109
|
+
@worksheet.insert_cell(0,0,'test',nil,:down)
|
1110
|
+
@worksheet[0][0].value.should == 'test'
|
1111
|
+
@worksheet[0][1].value.should == '0:1'
|
1112
|
+
@worksheet[1][0].value.should == '0:0'
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
it 'should cause error if shift argument is specified whcih is not :right or :down' do
|
1116
|
+
lambda {
|
1117
|
+
@worksheet.insert_cell(0,0,'test',nil,:up)
|
1118
|
+
}.should raise_error
|
1119
|
+
end
|
1120
|
+
|
1121
|
+
it 'should cause error if a negative argument is passed in' do
|
1122
|
+
lambda {
|
1123
|
+
@worksheet.insert_cell(-1,-1)
|
1124
|
+
}.should raise_error
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
|
1093
1128
|
describe '.delete_cell' do
|
1094
1129
|
it 'should make a cell nil if no shift argument specified' do
|
1095
1130
|
deleted = @worksheet.delete_cell(0,0)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyXL
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vivek Bhagwat
|