Code Monkey home page Code Monkey logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
the problem is in the 
ExcelLibrary\Office\Excel\BinaryFileFormat\Encode\WorkSheetEncoder.cs file

Changing the encodecell routine to be like the one below resolved my issue with 
the library.

private static CellValue EncodeCell(Cell cell, SharedResource sharedResource)
        {
            object value = cell.Value;
            if (value is int || value is short)
            {
                RK rk = new RK();
                rk.Value = (uint)(Convert.ToInt32(value) << 2 | 2);
                return rk;
            }
            else if (value is decimal)
            {
                //if (Math.Abs((decimal)value) <= (decimal)5368709.11)
                //{
                //    RK rk = new RK();
                //    rk.Value = (uint)((int)((decimal)value * 100) << 2 | 3); // integer and mul
                //    return rk;
                //}
                //else
                //{
                    NUMBER number = new NUMBER();
                    number.Value = (double)(decimal)value;
                    return number;
                //}
            }
            else if (value is double)
            {
                //RK rk = new RK();
                //Int64 data = BitConverter.DoubleToInt64Bits((double)value);
                //rk.Value = (uint)(data >> 32) & 0xFFFFFFFC;
                //return rk;
                NUMBER number = new NUMBER();
                number.Value = (double)value;
                return number;
            }
            else if (value is string)
            {
                LABELSST label = new LABELSST();
                label.SSTIndex = sharedResource.GetSSTIndex((string)value);
                return label;
            }
            else if (value is DateTime)
            {
                NUMBER number = new NUMBER();
                number.Value = sharedResource.EncodeDateTime((DateTime)value);
                return number;
            }
            else if (value is bool)
            {
                BOOLERR boolerr = new BOOLERR();
                boolerr.ValueType = 0;
                boolerr.Value = Convert.ToByte((bool)value);
                return boolerr;
            }
            else if (value is ErrorCode)
            {
                BOOLERR boolerr = new BOOLERR();
                boolerr.ValueType = 1;
                boolerr.Value = ((ErrorCode)value).Code;
                return boolerr;
            }
            else
            {
                throw new Exception("Invalid cell value.");
            }
        }

Original comment by [email protected] on 10 Jun 2010 at 4:24

from excellibrary.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 16, 2024
lewis:

I did exactly what you have done here. It works perfectly. However I would like 
to know why the code looked like that. I can not understand it, but it has to 
be a reason, that's for sure.
Is it going to be a new release containing these modifications in a near future 
?

Thanks in advance.
Ariel.

Original comment by [email protected] on 22 Aug 2012 at 12:05

from excellibrary.

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.