付出与汲取

aspose.cell 读取文件 报乱码

不废话直接上代码 主要注意是 红色代码部分

Aspose.Cells.TxtLoadOptions lo = new TxtLoadOptions();
         
            lo.Encoding = Encoding.Default;
            //创建一个Workbook和Worksheet对象
            Worksheet wkSheet = null;
            Workbook wkBook = new Workbook(strFileName,lo);
            wkBook.FileFormat = FileFormatType.CSV;

            wkSheet = wkBook.Worksheets[SheetIndex];

            Cells cells = wkSheet.Cells;

            //读取标头数据
            DataTable dt = cells.ExportDataTableAsString(SheetIndex, HeaderRowIndex, cells.MaxDataRow + 1, cells.MaxColumn + 1, true);

            //释放对象
            wkSheet = null;
            wkBook = null;

            //返回数据
            return dt;

转载于“凡的世界”博客

posted on 2019-11-28 19:47  付出与汲取  阅读(1018)  评论(0编辑  收藏  举报

导航