• 查找Excel的Sheetname的方法


    #region 查找Sheetname
            ///// <summary>
            ///// 找到sheetname
            ///// </summary>
            ///// <param name="filePath"></param>
            ///// <returns></returns>
            //private static string GetSheetName(string filePath)
            //{
            //    string sheetName = "";

            //    System.IO.FileStream tmpStream = File.OpenRead(filePath);
            //    byte[] fileByte = new byte[tmpStream.Length];
            //    tmpStream.Read(fileByte, 0, fileByte.Length);
            //    tmpStream.Close();

            //    byte[] tmpByte = new byte[]{Convert.ToByte(11),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),
            //   Convert.ToByte(11),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),Convert.ToByte(0),
            //   Convert.ToByte(30),Convert.ToByte(16),Convert.ToByte(0),Convert.ToByte(0)};

            //    int index = GetSheetIndex(fileByte, tmpByte);
            //    if (index > -1)
            //    {

            //        index += 16 + 12;
            //        System.Collections.ArrayList sheetNameList = new System.Collections.ArrayList();

            //        for (int i = index; i < fileByte.Length - 1; i++)
            //        {
            //            byte temp = fileByte[i];
            //            if (temp != Convert.ToByte(0))
            //                sheetNameList.Add(temp);
            //            else
            //                break;
            //        }
            //        byte[] sheetNameByte = new byte[sheetNameList.Count];
            //        for (int i = 0; i < sheetNameList.Count; i++)
            //            sheetNameByte[i] = Convert.ToByte(sheetNameList[i]);

            //        sheetName = System.Text.Encoding.Default.GetString(sheetNameByte);
            //    }
            //    return sheetName;
            //}
            ///// <summary>
            ///// 只供方法GetSheetName()使用
            ///// </summary>
            ///// <returns></returns>
            //private static int GetSheetIndex(byte[] FindTarget, byte[] FindItem)
            //{
            //    int index = -1;

            //    int FindItemLength = FindItem.Length;
            //    if (FindItemLength < 1) return -1;
            //    int FindTargetLength = FindTarget.Length;
            //    if ((FindTargetLength - 1) < FindItemLength) return -1;

            //    for (int i = FindTargetLength - FindItemLength - 1; i > -1; i--)
            //    {
            //        System.Collections.ArrayList tmpList = new System.Collections.ArrayList();
            //        int find = 0;
            //        for (int j = 0; j < FindItemLength; j++)
            //        {
            //            if (FindTarget[i + j] == FindItem[j]) find += 1;
            //        }
            //        if (find == FindItemLength)
            //        {
            //            index = i;
            //            break;
            //        }
            //    }
            //    return index;
            //}

  • 相关阅读:
    Python find() 方法
    enumerate函数
    【Unity】项目工程源码
    【Unity】UGUI聊天消息气泡 随文本内容自适应
    Unity读Excel 输出PC端(Windows)后不能读取的问题
    【C#】读取Excel中嵌套的Json对象,Json带斜杠的问题(其三)
    【C#】读取Excel中嵌套的Json对象,Json带斜杠的问题(其二)
    【C#】读取Excel中嵌套的Json对象,Json带斜杠的问题(其一)
    Unity输出PC端(Windows) 拖拽文件到app中
    Android Studio报错Error:Failed to open zip file. Gradle's dependency cache may be corrupt
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1787635.html
Copyright © 2020-2023  润新知