Open GoogleCodeExporter opened 9 years ago
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 lewisb...@gmail.com
on 10 Jun 2010 at 4:24
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 alejandr...@gmail.com
on 22 Aug 2012 at 12:05
Original issue reported on code.google.com by
simonsam...@googlemail.com
on 4 Aug 2009 at 3:53