коммит гнева

This commit is contained in:
antoc0der 2024-03-27 11:50:55 +04:00
parent 110b91bd1b
commit 8867ed2e7d
2 changed files with 19 additions and 28 deletions

View File

@ -26,7 +26,8 @@ namespace FlowerShopBusinessLogic.OfficePackage
{ {
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> { (flower.FlowerName, new WordTextProperties { Size = "24", }) }, Texts = new List<(string, WordTextProperties)> { (flower.FlowerName, new WordTextProperties { Size = "24", Bold = true }),
(" - цена " + flower.Price.ToString(), new WordTextProperties { Size = "24" }) },
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",

View File

@ -156,30 +156,24 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
var tableStyles = new TableStyles() var tableStyles = new TableStyles()
{ {
Count = 0U, Count = 0U,
DefaultTableStyle = DefaultTableStyle ="TableStyleMedium2",
"TableStyleMedium2",
DefaultPivotStyle = "PivotStyleLight16" DefaultPivotStyle = "PivotStyleLight16"
}; };
var stylesheetExtensionList = new StylesheetExtensionList(); var stylesheetExtensionList = new StylesheetExtensionList();
var stylesheetExtension1 = new StylesheetExtension() var stylesheetExtension1 = new StylesheetExtension()
{ {
Uri = Uri ="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
"{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
}; };
stylesheetExtension1.AddNamespaceDeclaration("x14", stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
stylesheetExtension1.Append(new SlicerStyles() stylesheetExtension1.Append(new SlicerStyles()
{ {
DefaultSlicerStyle = DefaultSlicerStyle = "SlicerStyleLight1"
"SlicerStyleLight1"
}); });
var stylesheetExtension2 = new StylesheetExtension() var stylesheetExtension2 = new StylesheetExtension()
{ {
Uri = Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}"
"{9260A510-F301-46a8-8635-F512D64BE5F5}"
}; };
stylesheetExtension2.AddNamespaceDeclaration("x15", stylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
stylesheetExtension2.Append(new TimelineStyles() stylesheetExtension2.Append(new TimelineStyles()
{ {
DefaultTimelineStyle = "TimeSlicerStyleLight1" DefaultTimelineStyle = "TimeSlicerStyleLight1"
@ -211,6 +205,8 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
_ => 0U, _ => 0U,
}; };
} }
// создаем книгу, добавляем туда листы
protected override void CreateExcel(ExcelInfo info) protected override void CreateExcel(ExcelInfo info)
{ {
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
@ -235,8 +231,7 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>(); var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData()); worksheetPart.Worksheet = new Worksheet(new SheetData());
// Добавляем лист в книгу // Добавляем лист в книгу
var sheets = var sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
_spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
var sheet = new Sheet() var sheet = new Sheet()
{ {
Id = Id =
@ -247,8 +242,8 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
sheets.Append(sheet); sheets.Append(sheet);
_worksheet = worksheetPart.Worksheet; _worksheet = worksheetPart.Worksheet;
} }
protected override void InsertCellInWorksheet(ExcelCellParameters
excelParams) protected override void InsertCellInWorksheet(ExcelCellParameters excelParams)
{ {
if (_worksheet == null || _shareStringPart == null) if (_worksheet == null || _shareStringPart == null)
{ {
@ -261,8 +256,7 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
} }
// Ищем строку, либо добавляем ее // Ищем строку, либо добавляем ее
Row row; Row row;
if (sheetData.Elements<Row>().Where(r => r.RowIndex! == if (sheetData.Elements<Row>().Where(r => r.RowIndex! == excelParams.RowIndex).Any())
excelParams.RowIndex).Any())
{ {
row = sheetData.Elements<Row>().Where(r => r.RowIndex! == row = sheetData.Elements<Row>().Where(r => r.RowIndex! ==
excelParams.RowIndex).First(); excelParams.RowIndex).First();
@ -274,11 +268,9 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
} }
// Ищем нужную ячейку // Ищем нужную ячейку
Cell cell; Cell cell;
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == if (row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).Any())
excelParams.CellReference).Any())
{ {
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == excelParams.CellReference).First();
excelParams.CellReference).First();
} }
else else
{ {
@ -303,15 +295,13 @@ namespace FlowerShopBusinessLogic.OfficePackage.Implements
cell = newCell; cell = newCell;
} }
// вставляем новый текст // вставляем новый текст
_shareStringPart.SharedStringTable.AppendChild(new _shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(excelParams.Text)));
SharedStringItem(new Text(excelParams.Text)));
_shareStringPart.SharedStringTable.Save(); _shareStringPart.SharedStringTable.Save();
cell.CellValue = new cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count(
) - 1).ToString());
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString); cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
cell.StyleIndex = GetStyleValue(excelParams.StyleInfo); cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
} }
// объединение ячеек
protected override void MergeCells(ExcelMergeParameters excelParams) protected override void MergeCells(ExcelMergeParameters excelParams)
{ {
if (_worksheet == null) if (_worksheet == null)