RhSolutions-AddIn/RhSolutions.AddIn/Services/NewPriceWriter.cs

35 lines
1000 B
C#
Raw Permalink Normal View History

2023-06-20 07:25:44 +03:00
#if !NET472
using System.Runtime.Versioning;
using RhSolutions.Tools;
#endif
using System.Text.RegularExpressions;
namespace RhSolutions.Services;
#if !NET472
[SupportedOSPlatform("windows")]
#endif
public class NewPriceWriter : ExcelWriterBase, IWriter, IDisposable
{
public NewPriceWriter(Application application, IAddInConfiguration configuration)
{
_application = application;
_resultBar = new();
_headers = configuration.GetPriceListHeaders();
_worksheet = OpenNewPrice(configuration.GetPriceListPath());
}
private Worksheet OpenNewPrice(string pricelistPath)
{
if (_application.Workbooks
.Cast<Workbook>()
.FirstOrDefault(w => w.FullName == pricelistPath) != null)
{
throw new ArgumentException("Шаблонный файл редактируется в другом месте");
}
return _application.Workbooks.Open(pricelistPath, null, true).ActiveSheet;
}
}