Esempio n. 1
0
        /// <summary>
        /// 设置起始行和读取的列索引, 在csv文件中读取数据,通过弹窗选择文件路径。
        /// </summary>
        /// <param name="startRow">要读取的起始行索引</param>
        /// <param name="columns">要读取的起始列索引</param>
        /// <param name="rowCount">要读取的行数,若小于等于0则读取全部行</param>
        /// <param name="encoding">编码方式</param>
        public static T[,] Read <T>(long startRow, long[] columns, long rowCount = 0, Encoding encoding = null)
        {
            string filePath = FileUtil.GetOpenFilePathFromDialog(FileExtName);

            return(Read <T>(filePath, startRow, columns, rowCount, encoding));
        }
Esempio n. 2
0
        /// <summary>
        /// 在csv文件中写入数据,通过弹窗选择文件路径,需指定数据类型
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="data">待写入文件的二维数组</param>
        /// <param name="writeMode">文件已存在时的写入模式</param>
        /// <param name="encoding">文件的编码格式。encoding为null时使用系统默认的编码格式</param>
        public static void WriteData <T>(T[,] data, WriteMode writeMode = WriteMode.OverLap, Encoding encoding = null)
        {
            string filePath = FileUtil.GetSaveFilePathFromDialog(FileExtName);

            WriteData(filePath, data, writeMode, encoding);
        }
Esempio n. 3
0
 /// <summary>
 /// 在csv文件中写入数据,通过弹窗选择文件路径,需配置文件路径
 /// </summary>
 /// <typeparam name="T">数据类型</typeparam>
 /// <param name="filePath">待写入文件的完整路径和名称</param>
 /// <param name="data">待写入文件的二维数组</param>
 /// <param name="writeMode">文件已存在时的写入模式</param>
 /// <param name="encoding">文件的编码格式。encoding为null时使用系统默认的编码格式</param>
 public static void WriteData <T>(string filePath, T[,] data, WriteMode writeMode = WriteMode.OverLap, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     StreamWriteData(filePath, data.GetEnumerator(), data.GetLength(0), data.GetLength(1), writeMode, encoding);
 }
Esempio n. 4
0
 /// <summary>
 /// 在csv文件中设置起始索引值,读取二维数组,需配置文件路径。
 /// </summary>
 /// <param name="startRow">要读取的起始行索引</param>
 /// <param name="filePath">csv文件路径和名称</param>
 /// <param name="startColumn">要读取的起始列索引</param>
 /// <param name="rowCount">要读取的行数,若小于等于0则读取全部行</param>
 /// <param name="columnCount">要读取的列数,若小于等于0则读取全部列</param>
 /// <param name="encoding">编码方式</param>
 /// <returns></returns>
 public static T[,] Read <T>(string filePath, long startRow = 0, long startColumn = 0, long rowCount = 0, long columnCount = 0, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     return(StreamReadData <T>(filePath, startRow, startColumn, rowCount, columnCount, encoding));
 }
Esempio n. 5
0
 public static ushort[,] ReadUShortData(string filePath, uint startRow, uint[] columns, uint rowCount = 0, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     return(StreamReadData <ushort>(filePath, startRow, columns, rowCount, encoding));
 }
Esempio n. 6
0
 public static uint[,] ReadUIntData(string filePath, uint startRow = 0, uint startColumn = 0, uint rowCount = 0, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     return(StreamReadData <uint>(filePath, startRow, startColumn, rowCount, encoding));
 }
Esempio n. 7
0
        public static ushort[,] ReadUShortData(uint startRow, uint[] columns, uint rowCount = 0, Encoding encoding = null)
        {
            string filePath = FileUtil.GetOpenFilePathFromDialog(FileExtName);

            return(ReadUShortData(filePath, startRow, columns, rowCount, encoding));
        }
Esempio n. 8
0
        public static uint[,] ReadUIntData(uint startRow = 0, uint startColumn = 0, uint rowCount = 0, Encoding encoding = null)
        {
            string filePath = FileUtil.GetOpenFilePathFromDialog(FileExtName);

            return(ReadUIntData(filePath, startRow, startColumn, rowCount, encoding));
        }
Esempio n. 9
0
 /// <summary>
 /// 在csv文件中设置要读取的行列索引值,读取一维数组,需配置文件路径。
 /// </summary>
 /// <typeparam name="T">数据类型</typeparam>
 /// <param name="filePath">csv文件路径和名称</param>
 /// <param name="majorOrder">读取数值的方向</param>
 /// <param name="index">读取的行/列索引值</param>
 /// <param name="startIndex">要读取的行/列的起始索引位置</param>
 /// <param name="readCount">读取的数组长度,若小于等于0则读取全部</param>
 /// <param name="encoding">编码方式</param>
 /// <returns></returns>
 public static T[] Read <T>(string filePath, MajorOrder majorOrder, long index, long startIndex = 0, long readCount = 0, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     return(StreamReadData <T>(filePath, index, startIndex, readCount, MajorOrder.Column == majorOrder, encoding));
 }
Esempio n. 10
0
        /// <summary>
        /// 在csv文件中设置要读取的行列索引值,读取一维数组,文件路径通过文件选择窗口配置
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="majorOrder">读取数值的方向</param>
        /// <param name="index">读取的行/列索引值</param>
        /// <param name="startIndex">要读取的行/列的起始索引位置</param>
        /// <param name="readCount">读取的数组长度,若小于等于0则读取全部</param>
        /// <param name="encoding">编码方式</param>
        /// <returns></returns>
        public static T[] Read <T>(MajorOrder majorOrder, long index, long startIndex = 0, long readCount = 0, Encoding encoding = null)
        {
            string filePath = FileUtil.GetOpenFilePathFromDialog(FileExtName);

            return(Read <T>(filePath, majorOrder, index, startIndex, readCount, encoding));
        }
Esempio n. 11
0
 /// <summary>
 ///  在csv文件中设置要读取的行列索引值数组,读取二维数组,需配置文件路径。
 /// </summary>
 /// <param name="filePath">csv文件路径和名称</param>
 /// <param name="rows">要读取的行的索引集合</param>
 /// <param name="columns">要读取的列的索引集合</param>
 /// <param name="encoding">编码方式</param>
 /// <returns></returns>
 public static T[,] Read <T>(string filePath, long[] rows, long[] columns, Encoding encoding = null)
 {
     FileUtil.CheckFilePath(filePath, FileExtName);
     return(StreamReadData <T>(filePath, rows, columns, encoding));
 }
Esempio n. 12
0
        /// <summary>
        /// 在csv文件中设置要读取的行列索引值数组,读取二维数组,通过弹窗选择文件路径。
        /// </summary>
        /// <param name="rows">要读取的行的索引集合</param>
        /// <param name="columns">要读取的列的索引集合</param>
        /// <param name="encoding">编码方式</param>
        /// <returns></returns>
        public static T[,] Read <T>(long[] rows, long[] columns, Encoding encoding = null)
        {
            string filePath = FileUtil.GetOpenFilePathFromDialog(FileExtName);

            return(Read <T>(filePath, rows, columns, encoding));
        }