logic/parser/TableExcelImportDat.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.IO;

namespace tablegen2.logic
{
    public static class TableExcelImportDat
    {
        public static TableExcelData importFile(string filePath)
        {
            var content = GzipHelper.processGZipDecode(File.ReadAllBytes(filePath));
            var ms = new MemoryStream(content);
            var br = new BinaryReader(ms);

            if (br.ReadInt32() != 1)
                throw new Exception("无法识别的文件版本号");

            var r = new TableExcelData();
            while (true)
            {
                var fieldName = br.ReadUtf8String();
                if (string.IsNullOrEmpty(fieldName))
                    break;

                var fieldType = string.Empty;
                var ftype = br.ReadByte();
                switch (ftype)
                {
                    case 1:
                        fieldType = "int";
                        break;
                    case 2:
                        fieldType = "float";
                        break;
                    case 3:
                        fieldType = "string";
                        break;
                    case 4:
                        fieldType = "long";
                        break;
                    case 5:
                        fieldType = "string[]";
                        break;
                    case 6:
                        fieldType = "int[]";
                        break;
                    case 7:
                        fieldType = "long[]";
                        break;
                    default:
                        throw new Exception(string.Format("无法识别的字段类型 fieldName:{0} fieldType:{1}", fieldName, ftype));
                }
                r.Headers.Add(new TableExcelHeader() { FieldName = fieldName, FieldType = fieldType });
            }

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                var lst = new List<string>();
                for (int i = 0; i < r.Headers.Count; i++)
                {
后面还有 29 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。