国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Unity用NPOI創(chuàng)建Exect表,保存數(shù)據(jù),和修改刪除數(shù)據(jù)。以及打包后的坑——無法打開新創(chuàng)建的Exect表

這篇具有很好參考價值的文章主要介紹了Unity用NPOI創(chuàng)建Exect表,保存數(shù)據(jù),和修改刪除數(shù)據(jù)。以及打包后的坑——無法打開新創(chuàng)建的Exect表。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

先說坑花了一下午才找到解決方法解決,

在Unity編輯模式下點擊物體創(chuàng)建對應(yīng)的表,獲取物體名字與在InputText填寫的注釋數(shù)據(jù)。然后保存。創(chuàng)建Exect表可以打開,打包PC后,點擊物體創(chuàng)建的表,打不開文件破損

解決方法:到unity編輯器所在路徑中去找這個路徑
\Editor\Data\MonoBleedingEdge\lib\mono\unityaot 或者 unityjit 文件夾或者unityaot-win32
找到里邊以”I18N“開頭的這四個dll文件

Unity用NPOI創(chuàng)建Exect表,保存數(shù)據(jù),和修改刪除數(shù)據(jù)。以及打包后的坑——無法打開新創(chuàng)建的Exect表,unity,游戲引擎

?

在這里感謝大佬:LAIALAIA

解決方法思路原版鏈接:unity 使用EPPlus對Excel的創(chuàng)建、寫入、讀取操作 - 噠噠噠~~~ - 博客園 (cnblogs.com)

創(chuàng)建讀取刪除Execel

?// 初始化 Excel 文件
?

 // 初始化 Excel 文件
        public void InitializeExcelFile(string ExcelFileName)
        {
        // 獲取應(yīng)用的數(shù)據(jù)文件夾路徑
        string dataPath = Application.streamingAssetsPath + "/Data";
        // 合并路徑,得到完整的 Excel 文件路徑
        excelFilePath = Path.Combine(dataPath, ExcelFileName + ".xls");
        // 創(chuàng)建一個文件信息對象來檢查 Excel 文件是否存在
        FileInfo excelFile = new FileInfo(excelFilePath);
        // 隱藏輸入框
        inputField.gameObject.SetActive(false);
        // 如果 Excel 文件不存在,創(chuàng)建一個新的 Excel 工作簿,并添加一個工作表
        if (!excelFile.Exists)
        {
            // 創(chuàng)建一個新的 Excel 工作簿對象
            workbook = new XSSFWorkbook();
            // 在工作簿中創(chuàng)建一個名為 "Comments" 的工作表
            sheet = (XSSFSheet)workbook.CreateSheet(ExcelFileName);
            // 在工作表的第一行(行索引為0)上創(chuàng)建一個新的行對象,并在該行中創(chuàng)建一個新的單元格對象(列索引為0)
            // 然后將 "Object Name" 這個字符串設(shè)置為單元格的值
            sheet.CreateRow(0).CreateCell(0).SetCellValue("Object Name");
            // 獲取工作表的第一行(行索引為0),然后在該行中創(chuàng)建一個新的單元格對象(列索引為1)
            // 然后將 "Comment" 這個字符串設(shè)置為單元格的值
            sheet.GetRow(0).CreateCell(1).SetCellValue("Comment");
        }
        else
        {
            using (FileStream fs = new FileStream(excelFilePath, FileMode.Open, FileAccess.Read))
            {
                workbook = new XSSFWorkbook(fs);
                sheet = (XSSFSheet)workbook.GetSheetAt(0);
            }
        }
    }

刪除文章來源地址http://www.zghlxwxcb.cn/news/detail-652243.html

? ?private void DeleteObjectFromExcel()
? ? {
? ? ? ? if (workbook == null || lastClickedObject == null)
? ? ? ? {
? ? ? ? ? ? Debug.LogError("Excel workbook is not initialized or no object clicked.");
? ? ? ? ? ? return;
? ? ? ? }

? ? ? ? string objectName = lastClickedObject.name;

? ? ? ? int rowIndex = FindRowIndexByObjectName(objectName);
? ? ? ? if (rowIndex >= 0)
? ? ? ? {
? ? ? ? ? ? // 刪除選定的行
? ? ? ? ? ? sheet.RemoveRow(sheet.GetRow(rowIndex));

? ? ? ? ? ? // 清空 InputField 的文本內(nèi)容
? ? ? ? ? ? inputField.text = "";

? ? ? ? ? ? for (int i = rowIndex + 1; i <= sheet.LastRowNum; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? IRow currentRow = sheet.GetRow(i);

? ? ? ? ? ? ? ? // 跳過已刪除的行
? ? ? ? ? ? ? ? if (currentRow == null)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? IRow newRow = sheet.CreateRow(i - 1); // 創(chuàng)建一個新行
? ? ? ? ? ? ? ? for (int j = 0; j < currentRow.LastCellNum; j++)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ICell currentCell = currentRow.GetCell(j);
? ? ? ? ? ? ? ? ? ? ICell newCell = newRow.CreateCell(j); // 創(chuàng)建一個新單元格
? ? ? ? ? ? ? ? ? ? if (currentCell != null)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? newCell.SetCellValue(currentCell.ToString());
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }

? ? ? ? ? ? // 清除最后一行
? ? ? ? ? ? sheet.RemoveRow(sheet.GetRow(sheet.LastRowNum));


? ? ? ? ? ? // 保存修改后的文件
? ? ? ? ? ? using (FileStream fs = new FileStream(excelFilePath, FileMode.Create, FileAccess.Write))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? workbook.Write(fs);
? ? ? ? ? ? }
? ? ? ? }
? ? }

到了這里,關(guān)于Unity用NPOI創(chuàng)建Exect表,保存數(shù)據(jù),和修改刪除數(shù)據(jù)。以及打包后的坑——無法打開新創(chuàng)建的Exect表的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包