- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Excel 模板,它有一个表格(范围:A4:AM5),我需要通过 EPPlus 插入行来扩展它。我的代码在文件中插入单元格值没有问题,但我需要根据第一列中插入的每个新值扩展表的行。
我尝试使用 InsertRow(5,1)
方法,但它显示一个异常
"System.ArgumentOutOfRangeException: 'Row cannot be less than 1. Parameter name: value'"
{System.ArgumentOutOfRangeException: Row cannot be less than 1. Parameter name: value > at OfficeOpenXml.ExcelCellAddress.set_Row(Int32 value) > at OfficeOpenXml.ExcelNamedRangeCollection.InsertRows(Int32 rowFrom, Int32 rows, ExcelNamedRange namedRange) > at OfficeOpenXml.ExcelNamedRangeCollection.Insert(Int32 rowFrom, Int32 colFrom, Int32 rows, Int32 cols, Func`2 filter) > at OfficeOpenXml.ExcelWorksheet.InsertRow(Int32 rowFrom, Int32 rows, Int32 copyStylesFromRow) > at TestInsertRow.Program.Main(String[] args)}
class Dnp3
{
private static ExcelPackage _dnp3Package;
private static ExcelWorksheet _worksheet1;
private static FileInfo _templateInfo;
private static FileInfo _newDnp3FileInfo;
public static bool TempFile
{
get
{
if (_templateInfo != null) return true;
return false;
}
set
{
if (value == true)
{
_templateInfo = new FileInfo(@" Existing template path ");
}
}
}
public static bool NewFile
{
get
{
if (_newDnp3FileInfo != null) return true;
return false;
}
set
{
if (value == true)
{
_newDnp3FileInfo = new FileInfo(@" Existing new file path ");
_dnp3Package = new ExcelPackage(_newDnp3FileInfo, _templateInfo);
{
_worksheet1 = Dnp3._dnp3Package.Workbook.Worksheets["DNP3_RTUs"];
{
_worksheet1.DataValidations.Clear();
}
}
}
}
}
public static bool Save
{
set
{
if (value == true)
{
Dnp3._dnp3Package.Save();
}
}
}
public class DNP3_RTUs : Dnp3
{
private int _idobj_nameCol;//IDOBJ_NAME
private int _idobj_aliasCol;//IDOBJ_ALIAS
private int _idobj_customidCol;//IDOBJ_CUSTOMID
private int _idobj_aorgroupCol;//IDOBJ_AORGROUP
public bool Header
{
set
{
int _column = 1;
_idobj_nameCol = 1;
_idobj_aliasCol = 1;
_idobj_customidCol = 1;
_idobj_aorgroupCol = 1;
if (value == true)
{
while (_worksheet1.Cells[Row: 3, Col: _column].Value != null)
{
switch (_worksheet1.Cells[Row: 3, Col: _column].Value)
{
case "IDOBJ_NAME":
_idobj_nameCol = _column;
break;
case "IDOBJ_ALIAS":
_idobj_aliasCol = _column;
break;
case "IDOBJ_CUSTOMID":
_idobj_customidCol = _column;
break;
case "IDOBJ_AORGROUP":
_idobj_aorgroupCol = _column;
break;
}
_column++;
}
}
}
}
public bool AddRow(int _line)
{
_line = _line + 5;
_worksheet1.InsertRow(_line, 2);
return false;
}
public string IDOBJ_NAME(int _line, string _data)
{
_line = _line + 5;//Pq a entrada de dados começa na linha
_worksheet1.Cells[_line, _idobj_nameCol].Value = _data;
_worksheet1.Cells[_line, _idobj_nameCol].Style.Font.Size = 11;
_worksheet1.Cells[_line, _idobj_nameCol].Style.Font.Name = "Calibri";
return "";
}
public string IDOBJ_ALIAS(int _line, string _data)
{
_line = _line + 5;//Pq a entrada de dados começa na linha 5
_worksheet1.Cells[_line, _idobj_aliasCol].Value = _data;
_worksheet1.Cells[_line, _idobj_aliasCol].Style.Font.Size = 11;
_worksheet1.Cells[_line, _idobj_aliasCol].Style.Font.Name = "Calibri";
return "";
}
public string IDOBJ_CUSTOMID(int _line, string _data)
{
_line = _line + 5;//Pq a entrada de dados começa na linha 5
_worksheet1.Cells[_line, _idobj_customidCol].Value = _data;
_worksheet1.Cells[_line, _idobj_customidCol].Style.Font.Size = 11;
_worksheet1.Cells[_line, _idobj_customidCol].Style.Font.Name = "Calibri";
return "";
}
public string IDOBJ_AORGROUP(int _line, string _data)
{
_line = _line + 5;//Pq a entrada de dados começa na linha 5
_worksheet1.Cells[_line, _idobj_aorgroupCol].Value = _data;
_worksheet1.Cells[_line, _idobj_aorgroupCol].Style.Font.Size = 11;
_worksheet1.Cells[_line, _idobj_aorgroupCol].Style.Font.Name = "Calibri";
return "";
}
}
}
class Program
{
static void Main(string[] args)
{
Dnp3.TempFile = true;
Dnp3.NewFile = true;
Dnp3.DNP3_RTUs dNP3_RTUs = new Dnp3.DNP3_RTUs() { Header = true };
int _mappingCount = 1;
dNP3_RTUs.IDOBJ_NAME(_mappingCount, "BOQ_1");
dNP3_RTUs.IDOBJ_ALIAS(_mappingCount,"nome_se_ordem");
dNP3_RTUs.IDOBJ_AORGROUP(_mappingCount, "mnem_se");
dNP3_RTUs.AddRow(_mappingCount);
Dnp3.Save = true;
}
}
最佳答案
我遇到了同样的异常,并且能够通过修复 excel 模板名称集合来解决它。
按 Ctrl+F3(名称管理器)并搜索包含任何 #REF 的名称! values 和referrers 并将它们从模板中删除。
关于c# - EPPlus - InsertRow : Row cannot be less than 1. 参数名称:值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55613182/
我正在遵循本教程的修改(简化)版本,非常类似于此处的内容: https://developer.apple.com/library/content/referencelibrary/GettingSt
我用通常的方式实现了 QAbstractTableModel: class PrintIntervalTableModel : public QAbstractTableModel { private
我有一个 QAbstractListModel 的子类,并用 GridView 附加了这个模型子类。当我从我的子类中删除行时,GridView 会更新,但是当我在模型中插入行时,GridView 不会
我正在为 myTableview 添加分页显示博客文章。数据源是一个帖子数组,即 posts = [post] . 我最初获取了 20 个帖子。我有一个按钮可以获取接下来的 20 条记录。所有这些都运
使用 var row = table.insertRow(id); 如何指定新行位于所使用的所选 ID 下,而不是硬编码索引或表末尾?我有一个下拉菜单,其中有不同的选项可以选择将新行放置在哪个行 ID
我试图在单击按钮后向表中插入一行,但收到下面的堆栈异常。 Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBound
我正在尝试像 Facebook 应用程序那样实现无限滚动。 Facebook 似乎正在以某种方式插入行或重新加载表格 View 而不停止当前滚动。 有人知道他们是如何实现这一目标的吗? 当我在滚动期间
我正在检测项目重新排列的模型/ View ,但我不明白如何重写 insertRows 方法。只是为了练习,我尝试用自定义结构包装 std::vector。 std::vector mD;//my da
我正在尝试编写一段 JavaScript 代码来根据输入文本框中提交的数字添加多行。我试图通过使用 FOR 循环来做到这一点,但由于某种原因它不起作用。你能向我解释一下为什么它没有插入与输入文本框中的
我是 javascript 的新手,但仍然倾向于尝试自己解决问题。但是,我感到很沮丧,因为相同的函数适用于略有不同的 HTML,但没有 tbody 和 thead。 我得到的错误是 --> Uncau
我在 ResultSet 中插入多行,如下所示,我需要在插入所有行后打印出 ResultSet,因此尝试将光标移回第一行之前,但失败并出现错误 - “此行错误:Java.lang.IllegalSta
向表中添加行的首选方法是什么? var tr = tbl.insertRow(-1); 或 var tr = document.createElement('tr');tbl.appendChild(
我正在尝试从 Chrome 扩展程序修改表的 insertRow 函数。 oldInsRowFunc = document.getElementById(id).insertRow; document
我有一个 JTable 和一个自定义表模型,在某些地方有 Double.class 作为列类。我从数据库中读取数据,然后将结果插入到表中。我希望数字以 2 位小数呈现,所以我使用此类 publ
希望有人能帮忙。我确信我缺少一些简单的东西。 用户通过单击“添加”按钮添加行,然后如果需要删除它,则单击“删除”以删除该行。 它会删除最初的行中的行,但我添加的行,它会刷新页面,并且我会丢失添加的所有
我尝试实现一个 tableView,其中行在行可见时插入带有动画的行。我更新数据源的数组并调用: [self.tableView insertRowsAtIndexPaths:addedIndexP
在表更新之前,我的表数据源只有一个部分,一行: 第 0 节 第 [0,0] 行 更新后数据源返回另外两个部分,每个部分只有一行: 第 0 节 第 [0,0] 行 第 1 节 第 [1,0] 行 第 2
我有以下类,代表数据结构中的记录: #ifndef UECONNECTEDCLIENTRECORD_H #define UECONNECTEDCLIENTRECORD_H #include #inc
背景和设置 我正在尝试从 javascript 中的表格数据创建一个表,但是当我尝试将行插入表元素时,它插入的顺序与我期望的顺序相反,与使用 appendChild 得到的顺序相反。 (这里是 a j
尝试更改方法来更新数据,因为 reloadData 有滞后 let oldIns = insertCounter insertCounter += Int(INSERT_MESSAGES) // +4
我是一名优秀的程序员,十分优秀!