Forced Int32
See original GitHub issueHello Mark,
I noticed an exception on below : {"Value must be non-negative and less than or equal to Int32.MaxValue. (Parameter 'count')"}
This is caused duet o the fact that one value is well above int32 range, although i though that it would be mapped as string?, those values are decimal in .xslb. spreadsheet. Value : “-11001000000”
I tried both mapping fields as decimal?, decimal. In my JoinHeaders() method, non of this worked. Once line was manually removed all worked fine.
private List<T>? SylvanReader<T>()
{
try
{
var options = new SylExcel.ExcelDataReaderOptions { Schema = SylExcel.ExcelSchema.Default, GetErrorAsNull = true };
//collect data
using (SylExcel.ExcelDataReader excelDataReader = SylExcel.ExcelDataReader.Create(Setup.FilePath, options))
{
//loop to locate needed sheet from passed setup
while (excelDataReader.WorksheetName != Setup.SheetName)
{
excelDataReader.NextResult();
if (excelDataReader.WorksheetName == null)
{
//throw exception, that sheet was not located
throw new Exception(string.Format("Didn't find the sheet: {0}", Setup.SheetName));
}
}
//loop to find headers, this will allow to skip unwanted rows, such as comments, empty lines etc.
for (int i = 0; i < Setup.StartRow; i++)
{
excelDataReader.Read();
}
//get all coulmns in file to column specified as max
//JoinHeaders is a method that returns array of needed sheets, and not needed as int.
//excample: Data1, Data2, 2, 3, Data3, 5 as string
var schema = Schema.Parse(Setup.JoinHeaders());
excelDataReader.InitializeSchema(schema.GetColumnSchema(), useHeaders: true);
//JoinHeaders is a method that returns only array of needed sheets.
//excample: Data1, Data2, Data3 as string[]
var dataReader = excelDataReader.Select(Setup.NeededHeaders());
var binderOptions = new DataBinderOptions
{
InferColumnTypeFromMember = true,
BindingMode = DataBindingMode.Any
};
DataBinder.Create<T>(dataReader, binderOptions);
return dataReader.GetList<T>().ToList();
}
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to force function to return int32 integers? - arrays
I want the values to be int from the start. This is what I tried : x = int32([0 0 0 0 0...
Read more >Casting and type conversions - C# Programming Guide
Convert class, and the Parse methods of the built-in numeric types, such as Int32.Parse. For more information, see How to convert a byte...
Read more >Int32 Struct (System)
Represents a 32-bit signed integer. public value class int : IComparable, IComparable<int>, IConvertible, IEquatable<int>, IFormattable
Read more >int int32 int64 are all distinct types, but float and float64 ...
So in my opinion it would be a forced code improvement. Agreed. But it will cause huge problems with backwards compatibility and Nim...
Read more >Options Constructor (SyncFilesCmdFlags, Int32, ...
The -f flag forces resynchronization even if the client already has the file, and overwriting any writable files. This flag doesn't affect open...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Okay, this ended up being a bug with reading records that span an internal buffer boundary. Just pushed 0.1.8 to nuget which contains the fix.
Okay, I can repro the exception with the file you sent. Will take a look and figure out what’s going on. Definitely a bug, but it isn’t obvious right away. Might not be able to investigate it right away, but I will try to look at it in the next few days.