你好我想删除一个表的空行,我发现了问题。
public ActionResult BillOfMaterials(Model model)
{
....
return File(@"C:\...(file path)...\result.pdf", "application /pdf");
}
我不知道如何写它,我尝试了几种方法,在这里寻找,但找不到具体的解决方案。如果Row完全为空,我想要删除。任何帮助非常感谢!
答案 0 :(得分:1)
我设法解决了这个问题!感谢所有真正打开我心灵的人。看下面,它很简单,做我想要的,宏也变得更快。
Range("Table[#Headers]").Select
Selection.AutoFilter
ActiveSheet.ListObjects("Table").Range.AutoFilter Field:=2, Criteria1:="="
Range("Table").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Range("Table[#Headers]").Select
ActiveSheet.ShowAllData
答案 1 :(得分:0)
尝试类似
的内容Dim ws as Worksheet
Set ws = ActiveWorkbook.Worksheets("SHEET NAME HERE")
Dim lRow as long
Dim rng as range
lRow = ws.Range("A" & Rows.Count).end(xlUp).row
'Assuming your table starts in column A, put in start/end row numbers
For each rng in ws.Range("A1:A" & lRow)
If ws.Range("A" & rng.row) = vbNullString then
ws.Rows(rng.row).Delete
End if
Next rng
答案 2 :(得分:0)
尝试删除工作表中的行时,请始终使用向后For
循环(例如For i = 100 to 1 Step -1
)。
检查某个Range
或Row
是否完全为空时,WorksheetFunction.CountA
非常方便。
Option Explicit
Sub DeleteEmptyRows()
Dim Rng As Range
Dim LastRow As Long
Dim lRow As Long
With Sheets("NewForecast")
Set Rng = .ListObjects("Table").Range
' find last row in "Table"
LastRow = .ListObjects("Table").Range.Rows.Count
' loop through all "Table" rows, loop backwards when deleting
For lRow = LastRow To 2 Step -1
' use CountA to check if entire row is empty
If WorksheetFunction.CountA(.Rows(lRow)) = 0 Then
.Rows(lRow).EntireRow.Delete
End If
Next
End With
End Sub
答案 3 :(得分:0)
这可以不循环。
然后使用:
public class DrugInfluence : INotifyPropertyChanged
{
public string Impairment { get; set; }
private bool _isChecked;
public bool IsChecked
{
get{ return _isChecked;}
set
{
if (_isChecked!= value)
{
_isChecked= value;
OnPropertyChanged("IsChecked");
}
};
}
}
如果您的值字段非常大但是在工作表和表格上工作并且比循环更快(更好),这可能很昂贵(需要很长时间)。