Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need skip type casting #12

Open
seapy opened this issue Apr 9, 2014 · 2 comments
Open

need skip type casting #12

seapy opened this issue Apr 9, 2014 · 2 comments

Comments

@seapy
Copy link

seapy commented Apr 9, 2014

some cell is needed original string.

in my case cell data is floating number(currency style), type is nil, but style is fixnum.
this case cell data is casting to integer.

optional skip type casting(not shared string) will be useful another case.
how do you think about this?

@woahdae
Copy link
Owner

woahdae commented May 22, 2014

Conceptualizing excel formatting without examples hurts my brain, could you include an example spreadsheet or a screenshot?

Skipping type casting is interesting. Currently, type casting is a static method since it's a functionally pure problem (same inputs always equal the same outputs), and I could change it to be configurable so you could supply your own typecasting method? Then you could implement yours as a no-op, or call to the default type caster and do post-processing, etc.

@seapy
Copy link
Author

seapy commented May 23, 2014

Sorry can't regenerate problem.
here is some screenshot. this screenshot case data cast to String, but sometimes cast number. i think it's depends on cell style.
workbook1

Maybe skipping type cast like this

module SimpleXlsxReader
  class Document
    class Mapper
      def self.cast(value, type, style, options = {})
        return nil if value.nil? || value.empty?

        case type
        when 's' # shared string
          options[:shared_strings][value.to_i]
        else
          value
        end
      end
    end
  end
end

@woahdae woahdae mentioned this issue Oct 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants