axlsx

Rails: Send a file generated by an axlsx view to a model

心已入冬 提交于 2019-12-12 05:12:22
问题 I am using the axlsx gem to generate excel spreadsheets. I am trying to send the generated spreadsheet to the model for zipping. This method zips the excel file with some other files. The method in my model looks like this: def zipper tempfile = Tempfile.new children = self.children_with_forms Zip::OutputStream.open(tempfile) do |stream| children.each do |child| directory = "#{child.wide_reference[0,3]}/" if child.model_name == "Position" stream.put_next_entry("#{child.volume} #{child.title}

How to write array to Excel with differing styles per column using Axlsx

a 夏天 提交于 2019-12-11 02:22:39
问题 I would like to be able to use the Axlsx gem to write out an Excel spreadsheet with different styles applied to different columns. I am writing an Array of Hashes an entire row at a time and, as a result, I cannot seem to format the columns differently as needed. I don't know how to say, "for columns A-D use default styling, however for column E and F, use horizontal center alignment". require 'axlsx' p = Axlsx::Package.new wb = p.workbook # Default Style for all cells standard_text = wb

generating xls file using axlsx

元气小坏坏 提交于 2019-12-10 18:27:25
问题 is there a way to generate XLS file using 'axlsx' gem? I'm already using this gem to generate xlsx files, and don't want to move it all to a different gem, especially since axlsx is much easier to work with. 回答1: Axlsx only generates xlsx files (it does not read them.) You'll have to use spreadsheet or roo or something else to directly create them. I rely on the downloadable Microsoft converter to change from xlsx to xls . I only generate one file, and as long as the xlsx file is not too

How to I add a hyperlink to a cell in axlsx?

徘徊边缘 提交于 2019-12-06 07:12:15
问题 With the spreadsheet gem, you can run Spreadsheet::Link.new('http://hyperlinkhere.com', 'Some words') to make a spreadsheet with a cell containing the string "Some words" with a hyperlink leading to "http://hyperlinkhere.com." What's the axlsx equivalent? EDIT: What if I want to write a row with more than one cell? With spreadsheet , you can do this: newSheetRow[13] = Spreadsheet::Link.new('url.com','text') newSheetRow[14] = 'some text' How do I do that with axlsx 's .add_row method? 回答1: You

Axlsx - Formatting text within a cell

∥☆過路亽.° 提交于 2019-12-05 02:34:11
问题 I can't seem to find any information on whether it's possible to fill a single cell with multiple formatting options. For example, I want cell A1 to be filled with the text: " Hello world, this is excel " Is this possible and if so what syntax do I use to do this? 回答1: For inline styling, use rich text. Here is an example from the axlsx page: p = Axlsx::Package.new p.use_shared_strings = true wb = p.workbook wrap_text = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical =>

How to I add a hyperlink to a cell in axlsx?

时光毁灭记忆、已成空白 提交于 2019-12-04 12:09:43
With the spreadsheet gem, you can run Spreadsheet::Link.new('http://hyperlinkhere.com', 'Some words') to make a spreadsheet with a cell containing the string "Some words" with a hyperlink leading to " http://hyperlinkhere.com ." What's the axlsx equivalent? EDIT: What if I want to write a row with more than one cell? With spreadsheet , you can do this: newSheetRow[13] = Spreadsheet::Link.new('url.com','text') newSheetRow[14] = 'some text' How do I do that with axlsx 's .add_row method? You can add both links within workbook and URLs. p = Axlsx::Package.new book = p.workbook book.add_worksheet(

How to give a date a background color with axlsx?

你说的曾经没有我的故事 提交于 2019-12-02 20:15:42
问题 I create an excel with axslx. One row should be colored. But if I do so, I loose the date format for my dates. Minimal example with some attempts I did: require 'axlsx' Axlsx::Package.new do |p| p.workbook.add_worksheet(:name => "test") do |ws| style1 = ws.styles.add_style(:bg_color => "EF0920", :fg_color => "FFFFFF") ws.add_row [ Date.today, "No style defined --ok"] ws.add_row [ Date.today, "Style with colors --The date is no date any longer"], :style => style1 ws.add_row [ Date.today,

Adding image to Excel file generated by Axlsx.?

自作多情 提交于 2019-12-02 14:01:51
问题 I am using Axlsx for generating Excel file. I need to add image to the Excel File. I have used this code : ws.add_image(:image_src => '../something',:noSelect => true, :noMove => true) do |image| image.width=1000 image.height=200 image.start_at 0,0 end where ' ws ' is the worksheet. It adds the required image, but i am not able to set the ' width ' & ' height ' of the image with this code. Even if i give width=2000 and height=1000 , it does not affect the image in Excel file. Can anybody tell

How to give a date a background color with axlsx?

时间秒杀一切 提交于 2019-12-02 12:34:49
I create an excel with axslx. One row should be colored. But if I do so, I loose the date format for my dates. Minimal example with some attempts I did: require 'axlsx' Axlsx::Package.new do |p| p.workbook.add_worksheet(:name => "test") do |ws| style1 = ws.styles.add_style(:bg_color => "EF0920", :fg_color => "FFFFFF") ws.add_row [ Date.today, "No style defined --ok"] ws.add_row [ Date.today, "Style with colors --The date is no date any longer"], :style => style1 ws.add_row [ Date.today, "Style with colors, except date -- ok, but not colored"], :style => [nil,style1] ws.add_row [ Date.today,

Adding image to Excel file generated by Axlsx.?

送分小仙女□ 提交于 2019-12-02 06:11:56
I am using Axlsx for generating Excel file. I need to add image to the Excel File. I have used this code : ws.add_image(:image_src => '../something',:noSelect => true, :noMove => true) do |image| image.width=1000 image.height=200 image.start_at 0,0 end where ' ws ' is the worksheet. It adds the required image, but i am not able to set the ' width ' & ' height ' of the image with this code. Even if i give width=2000 and height=1000 , it does not affect the image in Excel file. Can anybody tell , what i doing wrong.? This looks correct to me as well, and is inline with the example in the gem. wb