Giter VIP home page Giter VIP logo

Comments (5)

westonganger avatar westonganger commented on May 13, 2024

Okay so you cant do "#{amount} #{currency.symbol}" this is because the method is defined on the class which does not have the method amount or currency, that method is on the instance.

For the first one, can you try to write it like this: '"#{amount} #{currency.symbol}"' (notice the single quotes on the outside.)

For the second one, can you try to write it like this: '"#{reward.present? ? (reward.amount - reward.description) : I18n.t("payments.csv.no_rewards")}"' (notice the single quotes on the outside.)

The alternative to writing them like this is that you define a method on the instance

def the_amount
  "#{amount} #{currency_symbol}"
end

def the_reward
  reward.present? ? (reward.amount - reward.description) : I18n.t("payments.csv.no_rewards")
end

def self.spreadsheet_columns
  [
    [ "Date", "I18n.l(created_at.to_date, format: :long)" ],
    [ I18n.t('payments.csv.id'), :id ],
    [ I18n.t('payments.csv.login'), :payer_login ],
    [ I18n.t('payments.csv.email'), :payer_email ],
    [ I18n.t('payments.csv.firstname'), :payer_first_name ],
    [ I18n.t('payments.csv.lastname'), :payer_last_name ],
    [ I18n.t('payments.csv.type'), "type.slice(0, type.index('Payment'))" ],
    [ I18n.t('payments.csv.amount'), :the_amount],
    [ I18n.t('payments.csv.reward'), :the_reward],
    [ I18n.t('payments.csv.address'), 'try(:payer_location).try(:address_complete) || "-"' ]
  ]
end

Im going to look into the spreadsheet_columns method to see if it can be moved to the instance instead of the class possibly.

from spreadsheet_architect.

ldonnet avatar ldonnet commented on May 13, 2024

Yeah you are awesome it works!!

I have just a strange behaviour in excel (last version) contents in cell are underlined. Perhaps I need to specify specific style? Or a wrong default stylesheet?

Do you know if we could hide or show column for example if we need to display different informations for each controller?

Thanks for your great work and your time!

from spreadsheet_architect.

westonganger avatar westonganger commented on May 13, 2024

I am releasing 1.0.5 which includes moving the spreadsheet_columns method form the class to the instance after I deal with this underline issue. Do you think you could try it out using the options below to see if that works properly? If this works I will fix this in 1.0.5

.to_xlsx(header_style: {bold: :none}, row_style: {bold: :none}) 
# and
.to_xlsx(header_style: {bold: :single}, row_style: {bold: :single})

from spreadsheet_architect.

westonganger avatar westonganger commented on May 13, 2024

If you want to have different info per controller you can utilize the spreadsheet_columns option when you call to_xlsx . Though in 1.0.5 you must only use symbols methods when using this option.

from spreadsheet_architect.

westonganger avatar westonganger commented on May 13, 2024

I just released version 1.1.0 (which i was previously referring to 1.0.5). The spreadsheet_columns method has been moved from the class to the instance. See the Model section of the readme for new usage instructions. Also the underline issue should be fixed and should not require the underline option anymore and should work correctly with true/false

from spreadsheet_architect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.