功能更新
This commit is contained in:
42
RevitAddins/GlobalVariables.cs
Normal file
42
RevitAddins/GlobalVariables.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
using Autodesk.Windows;
|
||||
|
||||
using OfficeOpenXml;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
using System.Timers;
|
||||
|
||||
namespace RevitAddins
|
||||
{
|
||||
public static class GlobalVariables
|
||||
{
|
||||
public static IntPtr RevitWindowPtr => ComponentManager.ApplicationWindow;
|
||||
public static string AddInPath = typeof(GlobalVariables).Assembly.Location;
|
||||
public static string DirAssembly = Path.GetDirectoryName(AddInPath);
|
||||
public static Timer Timer { get; } = new();
|
||||
public static void TrimLastEmptyRows(this ExcelWorksheet worksheet)
|
||||
{
|
||||
while (worksheet.IsLastRowEmpty())
|
||||
{
|
||||
worksheet.DeleteRow(worksheet.Dimension.End.Row, 1);
|
||||
}
|
||||
}
|
||||
public static bool IsLastRowEmpty(this ExcelWorksheet worksheet)
|
||||
{
|
||||
List<bool> empties = [];
|
||||
|
||||
for (var index = 1; index <= worksheet.Dimension.End.Column; index++)
|
||||
{
|
||||
var value = worksheet.Cells[worksheet.Dimension.End.Row, index].Value;
|
||||
empties.Add(value == null || string.IsNullOrWhiteSpace(value.ToString()));
|
||||
}
|
||||
|
||||
return empties.All(e => e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user