小编use*_*769的帖子

尝试将粗体应用于整行,但继续获得空引用 - NPOI

我第一次将粗体应用于列,但我只想要一行而不是整列.所以我决定做同样的事情,但使用row.RowStyle.编译时没有错误,但我得到的是运行时错误r.RowStyle.SetFont(font);.我创建了一个类来处理与excel相关的所有内容,并且在这个类中我得到了这个错误(r.RowStyle.SetFont(font);):

处理了NullReferenceException

你调用的对象是空的.

调试整个过程而不是null.我不明白为什么我在使用RowStyle时会出现此错误,当我使用时CellStyle我没有收到该错误.

这是我的班级:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;   

using NPOI.HSSF.UserModel;
using NPOI.HPSF;
using NPOI.POIFS.FileSystem;
using NPOI.SS.UserModel;

using System.IO;


//works with everything related to excel
namespace takeMyTime_text
{
    class exelSheet
    {
            string exelPath; // where it's being saved

        HSSFWorkbook wb2 = new HSSFWorkbook();

        ISheet sheet;

        IRow r;

        IFont font;

        String[] headerTitles = { "Date", "In", "Out", "In", "Out", "Description" };

        // assing values to …
Run Code Online (Sandbox Code Playgroud)

c# npoi

3
推荐指数
1
解决办法
4259
查看次数

标签 统计

c# ×1

npoi ×1