Files
SzmediTools/Szmedi.Test/GlobalVariables.cs
2025-09-16 16:06:41 +08:00

40 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Timers;
using Autodesk.Windows;
using OfficeOpenXml;
namespace Szmedi.Test
{
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 (int index = 1; index <= worksheet.Dimension.End.Column; index++)
{
object value = worksheet.Cells[worksheet.Dimension.End.Row, index].Value;
empties.Add(value == null || string.IsNullOrWhiteSpace(value.ToString()));
}
return empties.All(e => e);
}
}
}