c# winForm使用Aspose.Cells读取CSV文件中文乱码问题

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

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 @ 2016-06-30 19:09  凡的世界  阅读(3796)  评论(0编辑  收藏  举报