我正在将数据从另一个 Excel 工作表写入 Excel 工作表。但是,列的数据可能如下所示:
$0.00
The amount owed at time of service is $33
20%
- 或空字符串。
我的问题是,当我将其写入文件时,Excel 将该列标记为“常规”以进行格式化,并且剥离了$
and%
并使其成为0.2
. 有没有办法将格式设置为纯字符串,以便在我写入电子表格时保持数据完整?
我是 Ruby 新手,所以如果您在代码中看到任何应该以其他方式完成的内容,请告诉我。
代码示例:
def self.add_data(new_book_sheet, old_book_sheet)
row_index = 9
header_row = 0
old_book_sheet.each do |row|
if header_row > 0
column_index = 0
row.each do |column|
new_book_sheet.row(row_index).insert(column_index, column)
column_index += 1
end
row_index += 1
end
header_row = 1
end
end