<< Masa.20101202-update-outline-sreadsheet | 2010 | Masa.20101130-update-bbmb-ch >>
1. git clone
2. src/testenvironment.rb (updated)
#!/usr/bin/env ruby
puts 'loading testenvironment'
class BbmbApp < SBSM::DRbServer
puts "disabling UPDATER"
remove_const :RUN_UPDATER
remove_const :RUN_STATISTICS
RUN_UPDATER = false
RUN_STATISTICS = false
print "BbmbApp::RUN_UPDATER="
p BbmbApp::RUN_UPDATER
end
module BBMB
class CustomBehaviorGag < CustomBehavior
remove_const :MAIL_RECIPIENTS
remove_const :MAIL_RECIPIENTS_CC
remove_const :MAIL_INJECT_RECIPIENTS
remove_const :MAIL_PDF_RECIPIENTS
remove_const :MAIL_PDF_RECIPIENTS_CC
remove_const :MAIL_PDF_FROM
remove_const :REMOTE_ACCESS
MAIL_RECIPIENTS = ['mhatakeyama@ywesee.com']
MAIL_RECIPIENTS_CC = []
MAIL_INJECT_RECIPIENTS = ['mhatakeyama@ywesee.com']
MAIL_PDF_RECIPIENTS = ['mhatakeyama@ywesee.com']
MAIL_PDF_RECIPIENTS_CC = []
MAIL_PDF_FROM = 'mhatakeyama@ywesee.com'
REMOTE_ACCESS = 'ftp://ftp_user1:passwd@localhost'
print "BBMB::CustomBehaviorGag::MAIL_RECIPIENTS"
p BBMB::CustomBehaviorGag::MAIL_RECIPIENTS
end
end
Note
3. src/custom/behavior.rb
def mail_send(mail, from, to)
smtp = Net::SMTP.new('localhost')
smtp.start {
begin
smtp.sendmail(mail.encoded(), from, to)
rescue Net::SMTPFatalError => error
error = TMail::Mail.new
error.from = from
#error.to = 'hwyss@ywesee.com'
error.to = 'mhatakeyama@ywesee.com'
error.subject = "Mail-Delivery Error!"
error.date = Time.now
etext = TMail::Mail.new
etext.set_content_type('text', 'plain', 'charset'=>'iso-8859-1')
etext.body = [
error,
error.message,
error.backtrace,
].join("\n")
error.parts << etext
smtp.sendmail(error.encoded(), from, to)
end
}
end
4. src/custom/lookandfeelgag.rb
#!/usr/bin/env ruby
# LookandfeelGag -- bbmb -- hwyss@ywesee.com
require "sbsm/lookandfeelwrapper"
module BBMB
class LookandfeelGag < SBSM::LookandfeelWrapper
DICTIONARIES = {
"de" => {
:new_customer_mail => "mailto:mhatakeyama@ywesee.com?subject=Neukunde BBMB - bitte Passwort generieren&",
:partner => "Masapharm AG",
:welcome => "Willkommen bei Masapharm",
}
}
ENABLED = [
:bcreader_usb,
]
end
end
5. src/util/bbmbconfig.rb
#!/usr/bin/env ruby
# BbmbConfig -- bbmb -- 09.04.2003 -- hwyss@ywesee.com
module BBMB
DEFAULT_FLAVOR = 'gag'
#SERVER_URI = ["druby://localhost:9999", "druby://192.168.0.35:9876"]
SERVER_URI = ["druby://localhost:9999", "druby://localhost:9876"]
def primary_uri
if(SERVER_URI.is_a? Array)
SERVER_URI.first
else
SERVER_URI.to_s
end
end
module_function :primary_uri
YAML_ODDB_URI = "druby://localhost:10004"
end
6. replace doc/resources/gag/logo.gif
7. src/util/session.rb#http_protocol
def http_protocol
#'https'
'http'
end
8. src/model/root.rb
INITIAL_VALUES = {
#:email => "hwyss@ywesee.com",
:email => "mhatakeyama@ywesee.com",
#:pass_hash => "eb5b821092e2f46b27c06a613d7a51dc",
:pass_hash => "0cc175b9c0f1b6a831c399e269772661",
}
PREFERENCES = {
9. src/util/bbmbapp.rb
# @updater = run_updater if RUN_UPDATER
# @statistics = run_statistics if RUN_STATISTICS
...
begin
# Reconfigure Application
require 'testenvironment'
rescue Exception => e
p e
print e.backtrace.pretty_inspect
end
10. copy dojo doc/resources/dojo
masa@masa ~/bbmb.ch_setup/doc/resources $ cp -r dojo ~/ywesee/bbmb.ch/doc/resources/
11. /etc/apache2/vhosts.d/05_bbmbch_vhost.conf
Start bbmb.ch/bin/bbmbd
Access to http://masapharm.bbmb.ch/
Make Admin, SubAdmin user, and Customer user
Points
Check log files
masa@masa ~/ywesee/bbmb.ch $ cat log/mnemonic/000000000000.commandLog
@commando:-Mnemonic::Mnemonic_Bbmb_mangled_setsroot:
@args[:
@commando:-Mnemonic::Mnemonic_Bbmb_mangled_setsroot: Time
@args[:
@creator"0:BMB::Transactiono:AddUserComman:yTimeu: Time
@values{:
addressaaaplz" 1111:reseller_ean130:reseller_shortgaguidnew:reseller_name"
locationaaa:pass_hash"%47bce5c74f589f4867dbd57e9ca9f808:
@creator"0:BMB::Transactiono:AddUserComman:inUseo:TimeRecoveryCommand:@recoveryTimeu: Time
@values{ :subadmin_keyall:reseller_shortgag:pass_hash"%47bce5c74f589f4867dbd57e9ca9f808:
email"subadmin@ywesee.com:@userclasscBBMB::SubAdminUser
12. load customer info
masa@masa ~ $ cat ftp_share/ywesee/Out/ywskund 584674;584674;22;ywesee;;Hatapharm AG;;hoge hoge 11;;CH;8000;hogehoge;011 / 111 22 33;;;011 / 111 22 44;customer@ywesee.com;
src/util/bbmbapp.rb
@updater = run_updater if RUN_UPDATER
...
def run_updater
puts "running updater thread"
Thread.new {
Thread.current.priority=-10
Thread.current.abort_on_exception = true
#today = (UPDATE_HOUR > Time.now.hour) ? Date.today : Date.today.next
today = Date.today
loop {
#next_run = Time.local(today.year, today.month, today.day, UPDATE_HOUR)
next_run = Time.local(today.year, today.month, today.day, Time.now.hour, Time.now.min + 1)
p Time.now
p next_run
sleep(next_run - Time.now)
update()
today = Date.today.next
}
}
end
src/custom/behavior.rb
...
REMOTE_ACCESS = 'ftp://ftp_user1:passwd@localhost'
...
UPDATES = [
#:update_stock,
#:update_suppliers,
:update_users,
#:update_user_access,
#:update_group_access,
#:update_user_article_prices,
#:update_user_article_discounts,
#:update_user_group_discounts,
#:update_user_volume_prices,
#:update_stock_atc,
#:update_sl,
#:update_atc_classes,
#:update_fachinfos,
]
...
def update_users
users = []
map = user_map
update_values(:users, USER_MAP) { |values|
unless(/Konditionskunde/.match(values[:address1]))
if(uid = map[values[:customer_id]])
values[:uid] = uid
else
values[:klass] = HospitalUser
end
users.push(values)
end
}
p "done update_users"
p users
users unless users.empty?
end
Reboot bbmbd
Result (bbmbd log)
Wed Dec 01 08:39:38 +0100 2010
Wed Dec 01 08:40:00 +0100 2010
BbmbApp::update - updating admin
update: update_users
"done update_users"
[{:fax=>"011 / 111 22 44", :phone_private=>"", :access_group=>"584674", :customer_id=>"584674", :plz=>"8000", :organisation=>"Hatapharm AG", :address1=>"", :group_short=>"ywesee", :address2=>"hoge hoge 11", :location=>"hogehoge", :drtitle=>"", :address3=>"", :phone_business=>"011 / 111 22 33", :klass=>BBMB::HospitalUser, :phone_mobile=>"", :email=>"customer@ywesee.com"}, {:fax=>nil, :phone_private=>nil, :access_group=>nil, :customer_id=>nil, :plz=>nil, :organisation=>nil, :address1=>nil, :group_short=>nil, :address2=>nil, :location=>nil, :drtitle=>nil, :address3=>nil, :phone_business=>nil, :klass=>BBMB::HospitalUser, :phone_mobile=>nil, :email=>nil}]
update_users done
Wed Dec 01 08:40:00 +0100 2010
Thu Dec 02 08:41:00 +0100 2010
Check log file
masa@masa ~/ywesee/bbmb.ch $ cat log/mnemonic/000000000002.commandLog
@commando:-Mnemonic::Mnemonic_Bbmb_mangled_setsroot:
@args[:
@creator"1:BMB::Transactiono:AddUserComman:yTimeu: Time
@values{:astrazeneca0:phone_private"fax"011 / 111 22 44:customer_id"
584674:access_group"
address1":firstname0: 584674plz" 8000:organisation"Hatapharm AG:
group_id0:group_short"anton0:
hogehoge:hoge hoge 11:ywesee:
comport0:phone_business"011 / 111 22 33:
lastname0: drtitle":customer_ean130:
gender0:phone_mobile":
@creator"1:BMB::Transactiono:AddUserComman:HospitalUseo:TimeRecoveryCommand:@recoveryTimeu: Time
address10:firstname0:strazeneca0:phone_private0fax0:customer_id0:access_group0plz0:organisation0:
location0:group_short0:nton0:
comport0:phone_business0:
lastname0: drtitle0:customer_ean130:
gender0:phone_mobile0:
email0:@userclasscBBMB::HospitalUser
Check the activation of a customer

Note
Question
If I click 'Bestellung auslosen' button, an error comes

Error message on browser
NoMethodError undefined method `key' for #
on terminal
"getin bbmbapp#send_order" ftp.puttextfile(/tmp/bbmb.5424.0, /Spital/Temp/KD584674_1291195787.dat) Net::FTPPermError 553 Can't open that file: No such file or directory /usr/lib64/ruby/1.8/net/ftp.rb:243:in `getresp' /usr/lib64/ruby/1.8/net/ftp.rb:264:in `sendcmd' /usr/lib64/ruby/1.8/monitor.rb:242:in `synchronize' /usr/lib64/ruby/1.8/net/ftp.rb:262:in `sendcmd' /usr/lib64/ruby/1.8/net/ftp.rb:321:in `transfercmd' /usr/lib64/ruby/1.8/net/ftp.rb:469:in `storlines' /usr/lib64/ruby/1.8/monitor.rb:242:in `synchronize' /usr/lib64/ruby/1.8/net/ftp.rb:467:in `storlines' /usr/lib64/ruby/1.8/net/ftp.rb:572:in `puttextfile' /home/masa/ywesee/bbmb.ch/src/util/filehandler.rb:95:in `open' /home/masa/ywesee/bbmb.ch/src/util/ftptransaction.rb:14:in `ftpTransaction' /home/masa/ywesee/bbmb.ch/src/util/filehandler.rb:93:in `open' /home/masa/ywesee/bbmb.ch/src/custom/behavior.rb:491:in `transmit_order' /home/masa/ywesee/bbmb.ch/src/model/reseller.rb:48:in `send' /home/masa/ywesee/bbmb.ch/src/model/reseller.rb:48:in `method_missing' /home/masa/ywesee/bbmb.ch/src/model/hospital.rb:347:in `transmit_order' /home/masa/ywesee/bbmb.ch/src/util/bbmbapp.rb:586:in `send_order' /home/masa/ywesee/bbmb.ch/src/util/bbmbapp.rb:585:in `synchronize' /home/masa/ywesee/bbmb.ch/src/util/bbmbapp.rb:585:in `send_order' /home/masa/ywesee/bbmb.ch/src/state/current_order.rb:63:in `send_order' /usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:221:in `send' /usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:221:in `_trigger' /usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:210:in `trigger' /usr/lib64/ruby/site_ruby/1.8/sbsm/viralstate.rb:35:in `trigger' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:416:in `process' /home/masa/ywesee/bbmb.ch/src/util/session.rb:107:in `process' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:176:in `drb_process' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `synchronize' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `drb_process' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/bbmbd:15 bin/bbmbd:14:in `each' bin/bbmbd:14 error in SBSM::Session#to_html: /de/gag NoMethodError undefined method `key' for #<Net::FTPPermError:0x7fa58c586d38> /usr/lib64/ruby/site_ruby/1.8/htmlgrid/errormessage.rb:64:in `__messages' /usr/lib64/ruby/1.8/delegate.rb:136:in `sort_by' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/errormessage.rb:63:in `each' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/errormessage.rb:63:in `sort_by' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/errormessage.rb:63:in `__messages' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/errormessage.rb:36:in `error_message' /home/masa/ywesee/bbmb.ch/src/view/order.rb:56:in `init' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/component.rb:138:in `initialize' /home/masa/ywesee/bbmb.ch/src/view/compat.rb:47:in `initialize' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/template.rb:67:in `new' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/template.rb:67:in `__standard_component' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/template.rb:54:in `content' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `send' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `create' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:286:in `compose_component' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:209:in `compose' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:203:in `each' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:203:in `compose' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:55:in `init' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/component.rb:138:in `initialize' /usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:279:in `new' /usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:279:in `view' /usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:196:in `to_html' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:515:in `to_html' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:177:in `drb_process' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `synchronize' /usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `drb_process' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/bbmbd:15 bin/bbmbd:14:in `each' bin/bbmbd:14 BBMB::OrderViewGag::COMPONENTS[[0, 1]] in create(content)
Notes
Check files
masa@masa ~/ftp_share/Spital $ ls /tmp bbmb.5579.0 masa@masa ~/ftp_share/Spital $ cat /tmp/bbmb.5579.0 001:7601001000681 002:ORDERX 003:220 010:KD584674_1291196318.dat 100:YWESEE 101: 201:CU 202:584674 201:BY 202:1075 231:Hatapharm AG 237:61 250:ADE 251:1291196318 300:4 301:20101201 500:1 501:7680317060176 502:26203 520:1 521:PCE 540:2 541:20101201
Experiment (create directory and change group and access rights)
masa@masa ~/ftp_share/Spital $ ls -al insgesamt 0 drwxr-xr-x 4 masa masa 16 1. Dez 10:38 . drwxrwxr-x 4 masa ftp_group 40 1. Dez 10:14 .. drwxrwxr-x 2 masa ftp_group 1 1. Dez 10:14 In drwxrwxr-x 2 masa ftp_group 1 1. Dez 10:38 Temp
Result

Check files
masa@masa ~/ftp_share/Spital/In $ ls -al insgesamt 4 drwxrwxr-x 2 masa ftp_group 8 1. Dez 10:41 . drwxr-xr-x 4 masa masa 16 1. Dez 10:38 .. -rw------- 1 ftp_user ftp_group 248 1. Dez 10:41 KD584674_1291196511.dat masa@masa ~/ftp_share/Spital/In $ sudo cat KD584674_1291196511.dat 001:7601001000681 002:ORDERX 003:220 010:KD584674_1291196511.dat 100:YWESEE 101: 201:CU 202:584674 201:BY 202:1075 231:Hatapharm AG 237:61 250:ADE 251:1291196511 300:4 301:20101201 500:1 501:7680317060176 502:26203 520:1 521:PCE 540:2 541:20101201
Notes
Email install http://globopharm.bbmb.ch on your local machine
The shipping has to be simplfied to: Post Express Express auf Samstag
def init
if(@model.modifiable?)
components.update({
[0,1,0] => :priority_0,
[0,1,1] => 'priority_0',
#[1,1] => 'priority_explain_0',
[0,2,0] => :priority_1,
[0,2,1] => 'priority_1',
[1,2] => 'priority_explain_1',
[0,3,0] => :priority_13,
[0,3,1] => 'priority_13',
[1,3] => 'priority_explain_13',
[0,4,0] => :priority_16,
[0,4,1] => 'priority_16',
[1,4] => 'priority_explain_16',
# [0,5,0] => :priority_21,
# [0,5,1] => 'priority_21',
# [1,5] => 'priority_explain_21',
# [0,6,0] => :priority_40,
# [0,6,1] => 'priority_40',
# [1,6] => 'priority_explain_40',
# [0,7,0] => :priority_41,
# [0,7,1] => 'priority_41',
# [1,7] => 'priority_explain_41',
})
css_map.store([0,0,2,8], 'list')
else
components.store([0,1], :priority_value)
css_map.store([0,1], 'list')
end
super
end
Result

Reference
Check testcases
masa@masa ~/ywesee/spreadsheet $ ruby test/suite.rb Loaded suite test/suite Started ..........................F.................... Finished in 0.966987 seconds. 1) Failure: test_read_baltic(Spreadsheet::TestIntegration) [./test/integration.rb:1276]: Exception raised: Class: <Errno::ENOENT> Message: <"No such file or directory - /home/masa/ywesee/spreadsheet/test/data/test_baltic.xls"> ---Backtrace--- /home/masa/ywesee/spreadsheet/lib/spreadsheet.rb:68:in `initialize' /home/masa/ywesee/spreadsheet/lib/spreadsheet.rb:68:in `open' /home/masa/ywesee/spreadsheet/lib/spreadsheet.rb:68:in `open' ./test/integration.rb:1277:in `test_read_baltic' ./test/integration.rb:1276:in `test_read_baltic' --------------- 47 tests, 924 assertions, 1 failures, 0 errors
Notes
test.rb
require 'spreadsheet'
sheet = Spreadsheet.open('test.xls', 'rb').worksheet(0)
sheet.column(1).each do |v|
print v,"\n"
end
Result
masa@masa ~/work $ ruby test.rb a b c d e
Note
test1.xls (without grouping)

test2.xls (with grouping)

Result
masa@masa ~/ywesee/spreadsheet $ cat test.rb require 'spreadsheet' file = ARGV[0] sheet = Spreadsheet.open(file, 'rb').worksheet(0) sheet.column(0).each do |v| print v,"\n" end sheet.column(1).each do |v| print v,"\n" end sheet.column(2).each do |v| print v,"\n" end masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test1.xls 1.0 2.0 3.0 4.0 5.0 a b c d e 11.0 22.0 33.0 44.0 55.0 masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test2.xls 1.0 2.0 3.0 4.0 5.0 a b c d e 11.0 22.0 33.0 44.0 55.0 masa@masa ~/ywesee/spreadsheet $ ls -al -rwxr--r-- 1 masa masa 23552 1. Dez 14:54 test1.xls -rwxr--r-- 1 masa masa 23552 1. Dez 14:54 test2.xls
Notes
Experiment
lib/spreadsheet/excel/reader.rb#read_colinfo
def read_colinfo worksheet, work, pos, len
p "getin Spreadsheet::Excel::Reader#read_colinfo"
# Offset Size Contents
# 0 2 Index to first column in the range
# 2 2 Index to last column in the range
# 4 2 Width of the columns in 1/256 of the width of the zero
# character, using default font (first FONT record in the
# file)
# 6 2 Index to XF record (➜ 6.115) for default column formatting
# 8 2 Option flags:
# Bits Mask Contents
# 0 0x0001 1 = Columns are hidden
# 10-8 0x0700 Outline level of the columns (0 = no outline)
# 12 0x1000 1 = Columns are collapsed
# 10 2 Not used
first, last, width, xf, opts = work.unpack binfmt(:colinfo)[0..-2]
print " first=", first, "\n"
print " last=", last, "\n"
print " xf=", xf, "\n"
print " opts=", opts, "\n"
Result
masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test1.xls 1.0 2.0 3.0 4.0 5.0 a b c d e 11.0 22.0 33.0 44.0 55.0 masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test2.xls "getin Spreadsheet::Excel::Reader#read_colinfo" first=2 last=3 xf=15 opts=259 "getin Spreadsheet::Excel::Reader#read_colinfo" first=4 last=4 xf=15 opts=4096 1.0 2.0 3.0 4.0 5.0 a b c d e 11.0 22.0 33.0 44.0 55.0
Notes
References
Note
src/spreadsheet/excel/reader.rb#read_colinfo
def read_colinfo worksheet, work, pos, len
# Offset Size Contents
# 0 2 Index to first column in the range
# 2 2 Index to last column in the range
# 4 2 Width of the columns in 1/256 of the width of the zero
# character, using default font (first FONT record in the
# file)
# 6 2 Index to XF record (➜ 6.115) for default column formatting
# 8 2 Option flags:
# Bits Mask Contents
# 0 0x0001 1 = Columns are hidden
# 10-8 0x0700 Outline level of the columns (0 = no outline)
# 12 0x1000 1 = Columns are collapsed
# 10 2 Not used
Experiment (a sample to make a xls file)
masa@masa ~/ywesee/spreadsheet $ cat test.rb require 'spreadsheet' file = ARGV[0] book = Spreadsheet.open(file, 'rb') sheet= book.worksheet(0) sheet.column(0).each do |v| print v,"\n" end sheet.column(1).each do |v| print v,"\n" end sheet.column(2).each do |v| print v,"\n" end book.write "aaa.xls"
Result
masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test1.xls 1.0 2.0 3.0 4.0 5.0 a b c d e 11.0 22.0 33.0 44.0 55.0 masa@masa ~/ywesee/spreadsheet $ ls aaa.xls bin GUIDE.txt History.txt lib LICENSE.txt Manifest.txt Rakefile README.txt test1.xls test2.xls test.rb masa@masa ~/ywesee/spreadsheet $ diff test1.xls aaa.xls masa@masa ~/ywesee/spreadsheet $
Experiment lib/spreadsheet/column.rb
class Column
...
attr_accessor :width, :worksheet
attr_reader :default_format, :idx
attr_reader :outline_level
...
test.rb
require 'spreadsheet' file = ARGV[0] book = Spreadsheet.open(file, 'rb') sheet= book.worksheet(0) p sheet.column(0).outline_level p sheet.column(1).outline_level p sheet.column(2).outline_level p sheet.column(3).outline_level p sheet.column(4).outline_level p sheet.column(5).outline_level
Result
masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test1.xls 0 0 0 0 0 0 masa@masa ~/ywesee/spreadsheet $ ruby -I lib test.rb test2.xls 0 0 256 256 0 0
Note
Experiment
require 'spreadsheet' file = ARGV[0] book = Spreadsheet.open(file, 'rb') sheet= book.worksheet(0) sheet.column(2).hidden = true book.write "aaa.xls"
Result