2023-05-30 Unity 2进制6——Excel写入器ExcelWriter

news2024/9/28 15:23:26

文章目录

        • 一、Epplus 使用
        • 二、ExcelWriter
          • (一)文件结构
          • (二)操作说明
          • (三)操作示例
          • (四)完整代码

一、Epplus 使用

(一)获取 Excel 文件

string filePath = Application.dataPath + "/目标名称.xlsx"; // 这里是文件路径

FileInfo fileInfo = new FileInfo(filePath); // 获取 Excel 文件的信息,文件中没有这个文件不会报错

(二)打开 Excel 文件

// 打开 Excel
using (ExcelPackage excelPackage = new ExcelPackage(fileInfo)) {
    ...
}

(三)打开 / 创建 Excel 文件的某个表格

using (ExcelPackage excelPackage = new ExcelPackage(fileInfo)) {
   // 取得 Excel 文件中的第 1 张表
   ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1];
   
   // 取得 Excel 文件中名为 Sheet1 的表格
   ExcelWorksheet worksheet1 = excelPackage.Workbook.Worksheets["Sheet1"];
   
   // 在新 Excel 文件中创建叫 Sheet2 的表格
   ExcelWorksheet worksheet2 = excelPackage.Workbook.Worksheets.Add("Sheet2");
}

(四)读写数据

using (ExcelPackage excelPackage = new ExcelPackage(fileInfo)) {
    ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1];
    for (int i = worksheet.Dimension.Start.Row; i < worksheet.Dimension.End.Row; i++) { // 从有内容的最小行数开始,到最大行数结束 
        // Cells 是二维数组,第一个参数是读取第几行,第二个参数是读取第几列,需要 ToString 出数据
        // Cells 的索引从 1 开始!!!
        
        // 读取数据
        string s = worksheet.Cells[i, 1].Value.ToString();
        ...
        
        // 写入数据
        worksheet.Cells[i, 2].Value = "xxx";
        ...
        
        excelPackage.Save(); // 写入后保存表格
    }
}

(五)小结

操作代码
获得 Excel 文件ExcelPackage excelPackage = new ExcelPackage(fileInfo);
获取 Excel 文件的某个表格ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1];
ExcelWorksheet worksheet1 = excelPackage.Workbook.Worksheets["Sheet1"];
获得当前表格数目int i = excelPackage.Workbook.Worksheets.Count;
表格中最大行和列int row = worksheet.Dimension.End.Row;
int column = worksheet.Dimension.End.Column;
添加一张表格ExcelWorksheet worksheet2 = excelPackage.Workbook.Worksheets.Add("Sheet2");
获得表格中第 i 行 j 列的内容worksheet.Cells[i, j].Value.ToString();
保存修改后的 Excel 文件excelPackage.Save();

二、ExcelWriter

(一)文件结构
image-20230530040306303
类型名称说明
enumOrientation写入方向,垂直 or 水平
stringFILE_DIRECTORY存储 Excel 的文件夹位置
stringFILE_SUFFIX文件后缀名,默认为 .xlsx
ExcelWriterInstance单例模式实例化对象
functionstring GetDirectory(string fileName)获取文件名所在的目录,非外部提供的 API
functionvoid SetValue<T>(string fileName, string sheetName, int row, int column, T value) where T : struct
void SetValue(string fileName, string sheetName, int row, int column, string value)
写入单个数据,目前只支持值类型数据和字符串
functionvoid SetList<T>(string fileName, string sheetName, int row, int column, List<T> value, Orientation orientation) where T : struct
void SetList(string fileName, string sheetName, int row, int column, List<string> value, Orientation orientation)
写入列表数据,列表成员只支持值类型数据和字符串,可选垂直写入或竖直写入
functionvoid SetMemberList<T>(string fileName, string sheetName, int row, int column, List<T> value) where T : class写入多个自定义数据 T,T 的成员只支持值类型数据和字符串。横向排布 T 的数据内容,纵向排布 T 个数
functionvoid SetMemberDic<T, K>(string fileName, string sheetName, int row, int column, Dictionary<T, K> value) where T : struct where K : class
void SetMemberDic<K>(string fileName, string sheetName, int row, int column, Dictionary<string, K> value) where K : class
写入多个自定义数据 T,T 的成员只支持值类型数据和字符串。横向排布 T 的数据内容,纵向排布 T 个数。左侧会多加一列键
(二)操作说明
  • 参数 fileName 命名规则为 "xxx/xxx/xxx"xxx,寻找文件位置的规则为 FILE_DIRECTORY + fileName + FILE_SUFFIX。例如:

    ​ FILE_DIRECTORY = “C:\Data\”;

    ​ fileName = “你好”;

    ​ FILE_SUFFIX = “.xlsx”;

    则最终文件名为 "C:\Data\你好.xlsx"

  • sheetName 为 fileName 文件中的表名。若 sheetName 或 fileName 不存在,则会自动创建文件或表名;若已存在,则会打开已有文件进行写入。

  • 初始化相关操作可在函数 private ExcelWriter() { } 中填写。

  • 自定义内容仅支持公共变量,若需要写入私有变量,修改对应函数中的以下代码即可:

    FieldInfo[] fieldInfos = type.GetFields();
    
(三)操作示例

​ 以下操作中,FILE_DIRECTORY = Application.dataPath + "/Excel/";

(一)写入单个内容

​ 向 haha.xlsx 文件的 sheet!! 表中第 1 行第 2 列写入内容 “瓜”,第 2 行第 1 列写入内容 “呆瓜”:

ExcelWriter.Instance.SetValue("haha", "sheet!!", 1, 2, "瓜");
ExcelWriter.Instance.SetValue("haha", "sheet!!", 2, 1, "呆瓜");

​ 执行后会创建文件 haha.xlsx 并生成表 sheet!!。

image-20230529162813934 image-20230529162940956

(二)写入一行内容(列表)

​ 向 shabi2.xlsx 文件的 ei 表中以第 2 行第 2 列为起始位置水平写入列表内容:

List<string> ls = new List<string>() { "aa", "bb", "cc", "dd" };
ExcelWriter.Instance.SetList("shabi2", "ei", 2, 2, ls, ExcelWriter.Orientation.Horizontal);
image-20230529163212105 image-20230529163232176

(三)写入自定义数据(表格)

​ 自定义数据结构:

public class Man
{
    public int    id;
    public string name;
    public int    age;
    public float  height;
    public bool   sex;

    public Man(int id, string name, int age, float height, bool sex) {
        this.id     = id;
        this.name   = name;
        this.age    = age;
        this.height = height;
        this.sex    = sex;
    }
}

List<Man> lm = new List<Man>() {
   new Man(1, "daidai", 23, 175.2f, true),
   new Man(2, "dai", 53, 165.2f, true),
   new Man(3, "daid", 25, 173.4f, false),
   new Man(4, "d", 26, 176.2f, true),
   new Man(5, "daida", 27, 175.2f, false),
   new Man(6, "da", 43, 179.2f, true),
};

Dictionary<int, Man> dm = new Dictionary<int, Man>();
for (int i = 0; i < 6; i++) {
    dm[i] = lm[i];
}

​ 向 shabi2.xlsx 文件的 aasd 表中以第 4 行第 2 列为起始位置写入自定义列表内容:

ExcelWriter.Instance.SetMemberList<Man>("shabi2", "aasd", 4, 2, lm);
image-20230529164743204

​ 向 dashabi 目录下 aha.xlsx 文件的 aasd 表中以第 4 行第 2 列为起始位置写入自定义字典内容:

ExcelWriter.Instance.SetMemberDic<int, Man>("dashabi/aha", "aasd", 4, 2, dm);
image-20230529164929220
(四)完整代码
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using OfficeOpenXml;
using UnityEditor;
using UnityEngine;

/// <summary>
/// Excel 文件写入器
/// </summary>
public class ExcelWriter
{
    /// <summary>
    /// 写入方向
    /// </summary>
    public enum Orientation
    {
        Horizontal, // 水平写入
        Vertical    // 竖直写入
    }

    /// <summary>
    /// 存储 Excel 的文件夹位置
    /// </summary>
    private static readonly string FILE_DIRECTORY = Application.dataPath + "/Excel/";

    /// <summary>
    /// 文件后缀名,默认为 .xlsx
    /// </summary>
    private static readonly string FILE_SUFFIX = ".xlsx";

    public static ExcelWriter Instance { get; set; } = new ExcelWriter();

    private ExcelWriter() { }

    /// <summary>
    /// 获取文件名所在的目录
    /// </summary>
    /// <param name="fileName"></param>
    /// <returns></returns>
    private string GetDirectory(string fileName) {
        int index = fileName.LastIndexOf('/');
        if (index == -1) {
            return "";
        }
        return fileName.Substring(0, index);
    }

    /// <summary>
    /// 写入 Excel 数据
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入值</param>
    public void SetValue<T>(string fileName, string sheetName, int row, int column, T value) where T : struct {
        string   path     = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string   dir      = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path); // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            currentSheet.Cells[row, column].Value = value.ToString(); // 设值
            package.Save();                                           // 保存
        }
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 写入 Excel 数据
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入值</param>
    public void SetValue(string fileName, string sheetName, int row, int column, string value) {
        string path = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string dir  = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path);                      // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            currentSheet.Cells[row, column].Value = value; // 设值
            package.Save();                                // 保存
        }
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 写入 Excel 一行数组数据
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入数组</param>
    /// <param name="orientation">写入方向</param>
    public void SetList<T>(string fileName, string sheetName, int row, int column, List<T> value, Orientation orientation) where T : struct {
        string path = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string dir  = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path);                      // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            // 写入数组
            for (int i = 0; i < value.Count; i++) {
                switch (orientation) {
                    case Orientation.Horizontal:
                        currentSheet.Cells[row, column + i].Value = value[i].ToString();
                        break;
                    case Orientation.Vertical:
                        currentSheet.Cells[row + i, column].Value = value[i].ToString();
                        break;
                }
            }
            package.Save(); // 保存
        }
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 写入 Excel 一行数组数据
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入数组</param>
    /// <param name="orientation">写入方向</param>
    public void SetList(string fileName, string sheetName, int row, int column, List<string> value, Orientation orientation) {
        string path = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string dir  = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path);                      // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            // 写入数组
            for (int i = 0; i < value.Count; i++) {
                switch (orientation) {
                    case Orientation.Horizontal:
                        currentSheet.Cells[row, column + i].Value = value[i];
                        break;
                    case Orientation.Vertical:
                        currentSheet.Cells[row + i, column].Value = value[i];
                        break;
                }
            }
            package.Save(); // 保存
        }
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 写入 Excel 成员数据,水平为成员字段,竖直为成员数
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入值</param>
    public void SetMemberList<T>(string fileName, string sheetName, int row, int column, List<T> value) where T : class {
        string path = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string dir  = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path);                      // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            Type        type       = typeof(T);
            FieldInfo[] fieldInfos = type.GetFields();

            // 写入字段名称
            for (int i = 0; i < fieldInfos.Length; i++) {
                currentSheet.Cells[row, column + i].Value = fieldInfos[i].Name;
            }

            // 写入数据
            for (int i = 0; i < value.Count; i++) {
                for (int j = 0; j < fieldInfos.Length; j++) {
                    currentSheet.Cells[row + i + 1, column + j].Value = fieldInfos[j].GetValue(value[i]).ToString();
                }
            }
            package.Save(); // 保存
        }
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 写入 Excel 成员数据,水平为成员字段,竖直为成员数
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入值</param>
    public void SetMemberDic<T, K>(string fileName, string sheetName, int row, int column, Dictionary<T, K> value) where T : struct where K : class {
        string path = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string dir  = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path);                      // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            Type        typeT      = typeof(T);
            Type        typeK      = typeof(K);
            FieldInfo[] fieldInfos = typeK.GetFields();

            // 写入字段名称
            currentSheet.Cells[row, column].Value = typeT.Name;
            for (int i = 0; i < fieldInfos.Length; i++) {
                currentSheet.Cells[row, column + i + 1].Value = fieldInfos[i].Name;
            }

            // 写入数据
            int index = 0;
            foreach (KeyValuePair<T, K> pair in value) {
                currentSheet.Cells[row + index + 1, column].Value = pair.Key.ToString();
                for (int j = 0; j < fieldInfos.Length; j++) {
                    currentSheet.Cells[row + index + 1, column + j + 1].Value = fieldInfos[j].GetValue(pair.Value).ToString();
                }
                index++;
            }
            package.Save(); // 保存
        }
        AssetDatabase.Refresh();
    }

    /// <summary>
    /// 写入 Excel 成员数据,水平为成员字段,竖直为成员数
    /// </summary>
    /// <param name="fileName">Excel 文件名</param>
    /// <param name="sheetName">Excel 表名</param>
    /// <param name="row">行号(从 1 开始)</param>
    /// <param name="column">列号(从 1 开始)</param>
    /// <param name="value">写入值</param>
    public void SetMemberDic<K>(string fileName, string sheetName, int row, int column, Dictionary<string, K> value) where K : class {
        string path = FILE_DIRECTORY + fileName + FILE_SUFFIX; // 文件路径
        string dir  = FILE_DIRECTORY + GetDirectory(fileName);

        if (!Directory.Exists(dir)) {
            Directory.CreateDirectory(dir);
        }
        
        FileInfo fileInfo = new FileInfo(path);                      // 获取文件信息

        // 打开 Excel,不存在不会创建
        using (ExcelPackage package = new ExcelPackage(fileInfo)) {
            ExcelWorksheets worksheets = package.Workbook.Worksheets; // 获取所有表格

            // 寻找是否有对应名字的表格
            ExcelWorksheet currentSheet = null;
            foreach (ExcelWorksheet worksheet in worksheets) {
                if (worksheet.Name == sheetName) {
                    currentSheet = worksheet;
                    break;
                }
            }
            if (currentSheet == null) {
                currentSheet = worksheets.Add(sheetName); // 不存在,则会创建表;如果 Excel 不存在,也会一并创建
            }

            Type        typeK      = typeof(K);
            FieldInfo[] fieldInfos = typeK.GetFields();

            // 写入字段名称
            currentSheet.Cells[row, column].Value = "string";
            for (int i = 0; i < fieldInfos.Length; i++) {
                currentSheet.Cells[row, column + i + 1].Value = fieldInfos[i].Name;
            }

            // 写入数据
            int index = 0;
            foreach (KeyValuePair<string, K> pair in value) {
                currentSheet.Cells[row + index + 1, column].Value = pair.Key;
                for (int j = 0; j < fieldInfos.Length; j++) {
                    currentSheet.Cells[row + index + 1, column + j + 1].Value = fieldInfos[j].GetValue(pair.Value).ToString();
                }
                index++;
            }
            package.Save(); // 保存
        }
        AssetDatabase.Refresh();
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/586931.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一图看懂 autopep8 模块:自动格式化Python代码,以使其符合PEP8规范,资料整理+笔记(大全)

本文由 大侠(AhcaoZhu)原创&#xff0c;转载请声明。 链接: https://blog.csdn.net/Ahcao2008 一图看懂 autopep8 模块&#xff1a;自动格式化Python代码,以使其符合PEP8规范&#xff0c;资料整理笔记&#xff08;大全&#xff09; &#x1f9ca;摘要&#x1f9ca;模块图&#…

2022年软件测试人员调查统计

1、软件测试从业人员的年龄分布 测试行业的主力军年龄分布主要是集中在 26-30 岁这个区间&#xff0c;这部分的群体承担着行 业发展的主导力量&#xff0c;占 43.2%。根据数据显示&#xff0c;被调查者中占比最多的是 26-30 岁区间的软件测试从业人员&#xff0c;26-30 岁的测试…

Vue--》Vue3打造可扩展的项目管理系统后台的完整指南(二)

今天开始使用 vue3 ts 搭建一个项目管理的后台&#xff0c;因为文章会将项目的每一个地方代码的书写都会讲解到&#xff0c;所以本项目会分成好几篇文章进行讲解&#xff0c;我会在最后一篇文章中会将项目代码开源到我的GithHub上&#xff0c;大家可以自行去进行下载运行&…

Leetcode 2455 可被三整除的偶数的平均值

Leetcode 2455 可被三整除的偶数的平均值 来源&#xff1a;力扣&#xff08;LeetCode&#xff09; 链接&#xff1a;https://leetcode.cn/problems/average-value-of-even-numbers-that-are-divisible-by-three/description/ 博主Github&#xff1a;https://github.com/GDUT-…

Paper:《Is GPT-4 a Good Data Analyst?GPT-4是一个好的数据分析师吗?》翻译与解读

Paper&#xff1a;《Is GPT-4 a Good Data Analyst?GPT-4是一个好的数据分析师吗&#xff1f;》翻译与解读 导读&#xff1a;该论文提出了一个框架&#xff0c;用来引导GPT-4进行端到端的数据分析任务&#xff0c;包括数据提取、可视化生成以及数据分析。GPT-4 能生成SQL查询来…

chatgpt赋能python:Python中的切片操作

Python中的切片操作 介绍 在Python中&#xff0c;切片操作是一种常用的操作方式&#xff0c;可以快速地获取列表、元组、字符串等类型的一部分数据。切片操作通常使用冒号来表示&#xff0c;其形式为[start:stop:step]&#xff0c;其中start是起始位置,stop是结束位置(不包含…

编译型语言和解释型语言的定义与区别

目录 编译型语言 1) 可执行程序不能跨平台 2) 源代码不能跨平台 解释型语言 关于Python 总结 通过高级语言编写的源码&#xff0c;我们能够轻松理解&#xff0c;但对于计算机来说&#xff0c;它只认识二进制指令&#xff0c;源码就是天书&#xff0c;根本无法识别。源码要…

redhat7多种服务配置(Telnet/VNC/FTP/HTTP/Samba)

老师布置的作业,然后就是配置成功了,像重新配置一遍,也对此总结一下. 链接是参考&#xff0c;可以不用看&#xff0c;直接从我写的主体部分开始&#xff0c;要输入的命令我都有标注&#xff0c;没标注的都是说明&#xff0c;不用从链接里面开始哈!!!! 假设我们一直把yum配置好…

SQL server入门一【简单介绍与简单建表】

SQLserver登录方式 Windows身份验证 用户名登录 通常登录名为sa&#xff0c;密码为下载时设置的密码 SQL server建立一个数据库 数据库中建表存储数据(输入命令建表) 数据库的简单介绍与概念 含义 可以对数据进行存储和管理的软件以及数据本身统称为数据库 组成 数据库由表…

chatgpt赋能python:Python中安装re模块–详细介绍与步骤

Python中安装re模块 – 详细介绍与步骤 Python中的re模块是一种强大的正则表达式工具&#xff0c;它可以让我们快速方便地进行字符串的匹配和查找。在Python中安装re模块非常简单&#xff0c;本文将为大家详细介绍安装步骤。 什么是re模块 re模块是Python中的正则表达式模块…

Vue实例

1. 自定义元素 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content"widthdevice-wid…

SocketTools .NET Edition 11.0 Crack

SocketTools .NET Edition 一套 .NET 类&#xff0c;可轻松向软件添加 Internet 功能&#xff0c;支持 .NET 4.0 至 .NET 8.0。 特征 SocketTools 提供入门所需的一切&#xff0c;包括文档和示例&#xff0c;以及免费技术支持来回答您的开发问题。 Visual Studio 2022 和 .NE…

nodejs基于vue的医院在线挂号系统

本设计是在win10操作系统环境下&#xff0c;采取nodejs作为主要编程环境&#xff0c;通过nodejs语言使用sxpress框架&#xff0c;实现医院预约挂号系统。首先用户需要选定一个医生进行预约&#xff0c;医生可以通过预约&#xff0c;这里涉及到用户到医生的数据传输&#xff0c;…

软考A计划-试题模拟含答案解析-卷十

点击跳转专栏>Unity3D特效百例点击跳转专栏>案例项目实战源码点击跳转专栏>游戏脚本-辅助自动化点击跳转专栏>Android控件全解手册点击跳转专栏>Scratch编程案例 &#x1f449;关于作者 专注于Android/Unity和各种游戏开发技巧&#xff0c;以及各种资源分享&am…

网络犯罪宣传通告系统的设计与实现

摘要&#xff1a;在这个科技迅速发展的时代&#xff0c;我们迎来了互联网的时期&#xff0c;它使我们人类的生活变的更方便更快捷&#xff0c;但是它也带来了很多安全隐患。正视网络犯罪&#xff0c;正确去处理它&#xff0c;用有效的措施去预防犯罪去宣传网络犯罪的危害&#…

QT设置QPushButton样式

QPushButton *button new QPushButton("Button");// 设置样式表button->setStyleSheet("QPushButton {""background-color: rgb(181, 255, 184);""border-style: outset;""border-width: 2px;""border-radius: 10p…

Vue页面功能设计:随机生成一句名言或者励志的话

前言 最近在写自己的项目&#xff0c;发现脚注不知道写什么好。思来想去&#xff0c;反正是自己的写着玩的项目&#xff0c;没必要搞什么备案号之类的。倒不如每次加载页面的时候&#xff0c;随机生成一句名言或者励志的话激励自己。 代码实现 关于这种的功能实现&#xff0…

Games104现代游戏引擎学习笔记10

Physics Actors and Shapes Actor Static:静态actor&#xff0c;例如挡板等 Actor Dynamic&#xff1a;动态actor&#xff0c;例如可移动的箱子 Trigger&#xff1a;触发器 Actor-Kinematic&#xff1a;违背物理原则&#xff0c;由设计决定&#xff0c;不遵循真实物理原则 反物…

代码随想录算法训练营第四十三天 | 力扣 1049. 最后一块石头的重量 II, 494. 目标和, 474.一和零

1049. 最后一块石头的重量 II 题目 1049. 最后一块石头的重量 II 有一堆石头&#xff0c;用整数数组 stones 表示。其中 stones[i] 表示第 i 块石头的重量。 每一回合&#xff0c;从中选出任意两块石头&#xff0c;然后将它们一起粉碎。假设石头的重量分别为 x 和 y&#x…

Linux——什么是文件描述符?

目录 前文 一&#xff0c;为什么有文件描述符 二&#xff0c;什么是文件描述符 2.1 文件操作接口 2.2 文件描述符 三&#xff0c;文件描述符的原理 四&#xff0c;文件描述符的分配规则 前文 本文主要是详解一下文件描述符&#xff0c;我们从1.为什么&#xff1f;2.是什么&…