zoukankan      html  css  js  c++  java
  • C#中用OLEDB操作EXCEL时,单元格内容长度超过255被截断

    C#中Microsoft.ACE.OLEDB.12.0 驱动读取excel,会读取前8行来判定每列的数据类型,假如没有超过255个字符,那么会被设置为nvarchar(255),从第9行开始,超过255字符会被自动截断!
     
    推荐使用第三方库:
    ExcelDataReader
     
    Important note on .NET Core
    By default, ExcelDataReader throws a NotSupportedException "No data is available for encoding 1252." on .NET Core.
    To fix, add a dependency to the package System.Text.Encoding.CodePages and then add code to register the code page provider during application initialization (f.ex in Startup.cs):
    System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

    This is required to parse strings in binary BIFF2-5 Excel documents encoded with DOS-era code pages. These encodings are registered by default in the full .NET Framework, but not on .NET Core. 

     
  • 相关阅读:
    交换实验
    路由引入和控制
    ISIS
    BGP联盟
    BGP2
    bgp
    Linux日常总结
    配置本地yum源方法
    达梦数据库常见问题-安装
    达梦数据库常见问题-安装
  • 原文地址:https://www.cnblogs.com/OpenCoder/p/10513608.html
Copyright © 2011-2022 走看看