{"id":463559,"date":"2025-06-16T15:01:56","date_gmt":"2025-06-16T15:01:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=463559"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=463559","title":{"rendered":"<span>\u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0447\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 .NET \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e OpenXml. \u0427\u0430\u0441\u0442\u044c 3<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0420\u043e\u0434\u043e\u0432, \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u00ab\u0411\u0410\u0420\u0421 \u0413\u0440\u0443\u043f\u00bb, \u0430\u0432\u0442\u043e\u0440 \u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0447\u0430\u0442\u043d\u044b\u0445 \u0444\u043e\u0440\u043c Sprinter. \u042d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0451\u0439 \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a DocumentFormat.OpenXml \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0447\u0430\u0442\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u00ab\u043e\u0444\u0438\u0441\u043d\u044b\u0445\u00bb \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/barsgroup\/articles\/893810\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/barsgroup\/articles\/900920\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0442\u043e\u0440\u043e\u0439<\/a> \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0435\u0447\u044c \u0448\u043b\u0430 \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0435\u0447\u0430\u0442\u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e \u0437\u0430\u043a\u0430\u0437\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 docx. \u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0435\u0447\u0430\u0442\u0438 xlsx, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u041f\u041e \u043d\u0435 \u0440\u0435\u0436\u0435, \u0430, \u0431\u044b\u0442\u044c \u043c\u043e\u0436\u0435\u0442, \u0434\u0430\u0436\u0435 \u0447\u0430\u0449\u0435, \u0447\u0435\u043c docx. \u042d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0443 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0435\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u0445 \u0441\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0444\u043e\u0440\u043c\u0443\u043b \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5c5\/33f\/165\/5c533f165172f73185a919f0df3f5292.png\" width=\"500\" height=\"626\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/5c5\/33f\/165\/5c533f165172f73185a919f0df3f5292.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5c5\/33f\/165\/5c533f165172f73185a919f0df3f5292.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h3>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0442\u0443 \u0436\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438 \u0442\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0437\u0430\u043a\u0430\u0437\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043e\u043d\u043b\u0430\u0439\u043d-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 xlsx-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b53\/116\/57f\/b5311657f50edbf293b76fadb98af26b.png\" width=\"608\" height=\"301\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b53\/116\/57f\/b5311657f50edbf293b76fadb98af26b.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b53\/116\/57f\/b5311657f50edbf293b76fadb98af26b.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u00a0\u0437\u0430\u043a\u0430\u0437\u0430. \u0421\u0442\u043e\u043b\u0431\u0435\u0446\u00a0F (\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043d\u044b\u043c: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u00a0\u044f\u0447\u0435\u0439\u043a\u0430\u0445 \u0440\u0430\u0432\u043d\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u00a0\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u00a0\u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0442\u043e\u0432\u0430\u0440\u0430. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445\u00a0D \u0438\u00a0F\u00a0\u2014 \u0441\u0443\u043c\u043c\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u00a0\u044d\u0442\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0435\u043a \u0438\u00a0\u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u00a0\u044f\u0447\u0435\u0439\u043a\u0430\u0445.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/h3>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 docx, xlsx-\u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 (Parts), \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0438\u043b\u0438, \u043c\u0435\u0434\u0438\u0430\u0444\u0430\u0439\u043b\u044b, \u0438 \u0442.\u0434. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0434\u0440\u0443\u0433\u0438\u0435 \u0436\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code>private const int IntFormatId = 101; private const int DecimalFormatId = 102; private const int DateFormatId = 103; public async Task&lt;MemoryStream&gt; Print(PurchaseOrder order) {    var stream = new MemoryStream();    using var document = InitDocument(stream, order);    PrintPurchase(document, order);    document.Save();    return stream; } private SpreadsheetDocument InitDocument(MemoryStream stream, PurchaseOrder order) {    var doc = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook, true);    var workbookPart = doc.AddWorkbookPart();    workbookPart.Workbook = new Workbook();    #region \u0440\u0430\u0437\u0434\u0435\u043b \u0441\u0442\u0438\u043b\u0435\u0439    var stylesPart = workbookPart.AddNewPart&lt;WorkbookStylesPart&gt;();    stylesPart.Stylesheet = new Stylesheet    {        Fonts = new Fonts { Count = 1 },        Fills = new Fills { Count = 2 },        Borders = new Borders { Count = 1 },        CellFormats = new CellFormats { Count = 1 }    };    stylesPart.Stylesheet.Fonts.AppendChild(new Font());    stylesPart.Stylesheet.Fills.AppendChild(new Fill { PatternFill = new PatternFill { PatternType = PatternValues.None } });    stylesPart.Stylesheet.Fills.AppendChild(new Fill { PatternFill = new PatternFill { PatternType = PatternValues.Gray125 } });    stylesPart.Stylesheet.Borders.AppendChild(new Border());    stylesPart.Stylesheet.CellFormats.AppendChild(new CellFormat());    stylesPart.Stylesheet.NumberingFormats = new NumberingFormats(        new NumberingFormat { NumberFormatId = IntFormatId, FormatCode = \"#\" },        new NumberingFormat { NumberFormatId = DecimalFormatId, FormatCode = \"#.00\" },        new NumberingFormat { NumberFormatId = DateFormatId, FormatCode = \"dd.mm.yyyy\" });     #endregion    #region \u043e\u0431\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438    var sharedStringTablePart = workbookPart.AddNewPart&lt;SharedStringTablePart&gt;();    sharedStringTablePart.SharedStringTable = new SharedStringTable();       #endregion       #region \u0422\u0435\u043b\u043e \u0438 \u043b\u0438\u0441\u0442\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430       var currentSheetsCount = workbookPart!.WorksheetParts.Count();       var worksheetPart = workbookPart.AddNewPart&lt;WorksheetPart&gt;();    worksheetPart.Worksheet = new Worksheet();     worksheetPart.Worksheet.AppendChild(new Columns());    worksheetPart.Worksheet.AppendChild(new SheetData());    worksheetPart.Worksheet.AppendChild(new MergeCells());     var sheets = workbookPart.Workbook.GetFirstChild&lt;Sheets&gt;();    if (sheets == null)    {        sheets = workbookPart.Workbook.AppendChild(new Sheets());    }     sheets.Append(new Sheet    {        Name = $\"\u0417\u0430\u043a\u0430\u0437 \u2116{order.PurchaseNumber}\",        Id = workbookPart.GetIdOfPart(worksheetPart),        SheetId = (uint)currentSheetsCount + 1    });    #endregion    return doc; }<\/code><\/pre>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 Stylesheet.NumberingFormats. \u042d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0446\u0435\u043b\u044b\u0445 \u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u044f\u0447\u0435\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 InitDocument \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 (\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439) \u043b\u0438\u0441\u0442 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u0438\u043c\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u00a0\u043b\u0438\u0441\u0442 Excel \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0415\u0434\u0438\u043d\u0438\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u00a0\u2014 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b excel, \u0440\u0430\u0432\u043d\u044b\u0435 7\u00a0\u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 dpi=96.<\/p>\n<pre><code>private float CmToExcelCharacters(float cmSize) {    return cmSize \/ 2.54f * 96 \/ 7; }  private void PrintPurchase(SpreadsheetDocument document, PurchaseOrder order) {    #region \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043b\u0438\u0441\u0442\u0430       var rowCounter = 0u;    var worksheet = document.WorkbookPart!.WorksheetParts.First().Worksheet;    var sheet = worksheet.GetFirstChild&lt;SheetData&gt;()!;    var mergeCells = worksheet.GetFirstChild&lt;MergeCells&gt;();    var columns = worksheet.GetFirstChild&lt;Columns&gt;();     var stylesDict = new Dictionary&lt;StyleParams, uint&gt;();     columns.Append(        new Column { Min = 1, Max = 1, Width = CmToExcelCharacters(1), CustomWidth = true },        new Column { Min = 2, Max = 2, Width = CmToExcelCharacters(2), CustomWidth = true },        new Column { Min = 3, Max = 3, Width = CmToExcelCharacters(5), CustomWidth = true },        new Column { Min = 4, Max = 4, Width = CmToExcelCharacters(2.2f), CustomWidth = true },        new Column { Min = 5, Max = 5, Width = CmToExcelCharacters(2), CustomWidth = true },        new Column { Min = 6, Max = 6, Width = CmToExcelCharacters(2), CustomWidth = true });     #endregion    \/\/ ... }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0448\u0430\u043f\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b\u00a0\u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043e\u0431\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a (SharedStrings) \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430. \u0412\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u044f\u0447\u0435\u0435\u043a \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430\u00a0\u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u00a0\u0438\u0445\u00a0\u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0432\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0435, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438\u00a0\u2014 \u00ab\u043e\u0431\u0449\u0438\u0439\u00bb. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u00a0xlsx\u00a0\u2014 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0415\u0433\u043e \u043c\u044b\u00a0\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u00a0\u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<p>\u0412\u00a0\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435 \u043d\u0438\u0436\u0435, \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0448\u0430\u043f\u043a\u0438, \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0442\u0438\u043b\u0435\u0439 \u044f\u0447\u0435\u0435\u043a. \u0414\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e\u00a0\u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u0432\u00a0xlsx \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0438\u0436\u0435 \u0432\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<pre><code>\/\/\/ &lt;summary&gt; \/\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \/\/\/ &lt;\/summary&gt; private int AppendSharedString(SpreadsheetDocument document, string sharedString) {    OpenXmlElement siContent;    var textEl = new Text(sharedString) { Space = SpaceProcessingModeValues.Preserve };    siContent = textEl;    var sharedStringTablePart = document.WorkbookPart!.GetPartsOfType&lt;SharedStringTablePart&gt;().Single();    sharedStringTablePart.SharedStringTable.AppendChild(new SharedStringItem(siContent));     return sharedStringTablePart.SharedStringTable.ChildElements.Count - 1; } private void PrintPurchase(SpreadsheetDocument document, PurchaseOrder order) {     \/\/ ...    #region \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0448\u0430\u043f\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430       var titleStyle = basicStyle with { FontSize = 12, Bold = true };    AddTextRow($\"\u0417\u0430\u043a\u0430\u0437 \u2116{order.PurchaseNumber} \u043e\u0442 {order.PurchaseDate.ToLongDateString()}\", titleStyle);    AddTextRow($\"\u041a\u043b\u0438\u0435\u043d\u0442: {order.CustomerName}\", titleStyle);    AddTextRow($\"\u0410\u0434\u0440\u0435\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438: {order.CustomerAddress}\", titleStyle);     var tableHeaderStyle = basicStyle with { Bold = true, Fill = \"DDDDDD\" };    AddTextRow($\"\u0421\u043e\u0441\u0442\u0430\u0432 \u0437\u0430\u043a\u0430\u0437\u0430\", tableHeaderStyle with { FontSize = 12, HorizontalAlignment = HorizontalAlignmentValues.Center });       var tableTitlesRow = GetNextRow();    var tableTitles = new[] { \"\u2116\", \"\u041a\u043e\u0434\", \"\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\", \"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\", \"\u0426\u0435\u043d\u0430\", \"\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\" };    var cellIdx = 0;       foreach (var title in tableTitles)    {        var cell = CreateCell(tableTitlesRow, cellIdx++, tableHeaderStyle);        cell.CellValue = new CellValue(AppendSharedString(document, title));        cell.DataType = CellValues.SharedString;    }    #endregion     \/\/ ...    Row GetNextRow()    {        var r = new Row { RowIndex = ++rowCounter };        sheet.Append(r);         return r;    }    Cell CreateCell(Row row, int cellIndex, StyleParams styleParams, uint colSpan = 1)    {        var columnCode = Convert.ToChar('A' + cellIndex % 26);        var cellCode = $\"{columnCode}{rowCounter}\";        var cell = new Cell { CellReference = cellCode };         var styleId = FindOrAppendStyle(styleParams);        cell.StyleIndex = styleId;        row.Append(cell);        if (colSpan &gt; 1)        {            var endCol = Convert.ToChar(columnCode + colSpan - 1);            mergeCells!.AppendChild(new MergeCell            {                Reference = $\"{columnCode}{row.RowIndex}:{endCol}{row.RowIndex}\"            });            for (var i = 1; i &lt; colSpan; i++)            {                columnCode++;                cellCode = $\"{columnCode}{rowCounter}\";                row.Append(new Cell { CellReference = cellCode, StyleIndex = styleId });            }        }        return cell;    }    void AddTextRow(string text, StyleParams styleParams)    {        var textRow = GetNextRow();        var textCell = CreateCell(textRow, 0, styleParams, 6);        textCell.CellValue = new CellValue(text);        textCell.DataType = CellValues.String;    }    uint FindOrAppendStyle(StyleParams styleParams)    {        if (!stylesDict.TryGetValue(styleParams, out var styleId))        {            styleId = stylesDict[styleParams] = AppendTextStyle(document, styleParams);        }         return styleId;    } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 (Rows), \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u044f\u0447\u0435\u0439\u043a\u0430\u043c\u0438 (Cells). \u041a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0451 \u043d\u043e\u043c\u0435\u0440 (RowIndex), \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 1. \u041a\u0430\u0436\u0434\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434 (CellCode), \u0440\u0430\u0432\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0431\u0443\u043a\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, A1. \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u043a\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u043c\u043d\u043e\u0433\u043e\u0431\u0443\u043a\u0432\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0434\u043e\u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 Z. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0436\u0435 \u043a\u043e\u0434\u0435 \u044d\u0442\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u0447\u0442\u0435\u043d\u0430.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043a\u0430\u0437\u0430 \u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438. \u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u0443\u0434\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c, \u043d\u044e\u0430\u043d\u0441\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u0443\u043b, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u044b\u0445 \u044f\u0447\u0435\u0435\u043a \u0438 \u0442.\u0434. \u043f\u043e\u044f\u0441\u043d\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<pre><code>private void PrintPurchase(SpreadsheetDocument document, PurchaseOrder order) {    \/\/ ...    #region \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u0430\u0437\u0430    var rn = 0;    foreach (var item in order.Items)    {        rn++;        cellIdx = 0;        var itemRow = GetNextRow();               var numCell = CreateCell(itemRow, cellIdx++, basicStyle with { HorizontalAlignment = HorizontalAlignmentValues.Center, NumFormatId = IntFormatId });        numCell.CellValue = new CellValue(rn);        numCell.DataType = CellValues.Number;               var codeCell = CreateCell(itemRow, cellIdx++, basicStyle);        codeCell.CellValue = new CellValue(item.ProductCode);        codeCell.DataType = CellValues.String;               var nameCell = CreateCell(itemRow, cellIdx++, basicStyle);        nameCell.CellValue = new CellValue(item.ProductName);        nameCell.DataType = CellValues.String;               var cntCell = CreateCell(itemRow, cellIdx++, basicStyle with { HorizontalAlignment = HorizontalAlignmentValues.Center, NumFormatId = IntFormatId });        cntCell.CellValue = new CellValue(item.Count);        cntCell.DataType = CellValues.Number;               var priceCell = CreateCell(itemRow, cellIdx++, basicStyle with { HorizontalAlignment = HorizontalAlignmentValues.Center, NumFormatId = DecimalFormatId });        priceCell.CellValue = new CellValue(item.UnitPrice);        priceCell.DataType = CellValues.Number;               var sumCell = CreateCell(itemRow, cellIdx, basicStyle with { HorizontalAlignment = HorizontalAlignmentValues.Center, NumFormatId = DecimalFormatId });        sumCell.CellFormula = new CellFormula($\"{cntCell.CellReference}*{priceCell.CellReference}\");    }    #endregion     #region \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0438\u0442\u043e\u0433\u043e\u0432    var totalsRow = GetNextRow();    var totalsStyle = basicStyle with { Bold = true, HorizontalAlignment = HorizontalAlignmentValues.Center };    var totalsTitle = CreateCell(totalsRow, 0, totalsStyle with { HorizontalAlignment = HorizontalAlignmentValues.Right }, 3);    totalsTitle.CellValue = new CellValue(\"\u0418\u0422\u041e\u0413\u041e:\");    totalsTitle.DataType = CellValues.String;     var totalCountCell = CreateCell(totalsRow, 3, totalsStyle with { NumFormatId = IntFormatId });    totalCountCell.CellFormula = new CellFormula($\"SUM(D{totalsRow.RowIndex! - order.Items.Length}:D{totalsRow.RowIndex! - 1})\");    var emptyCell = CreateCell(totalsRow, 4, totalsStyle);    var totalSumCell = CreateCell(totalsRow, 5, totalsStyle with { NumFormatId = DecimalFormatId });    totalSumCell.CellFormula = new CellFormula($\"SUM(F{totalsRow.RowIndex! - order.Items.Length}:F{totalsRow.RowIndex! - 1})\");    #endregion    \/\/ ... }<\/code><\/pre>\n<h3>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0435\u043a<\/h3>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d3e\/684\/569\/d3e6845698cd61be4569e66806a2b1ca.png\" width=\"1170\" height=\"1249\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/d3e\/684\/569\/d3e6845698cd61be4569e66806a2b1ca.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d3e\/684\/569\/d3e6845698cd61be4569e66806a2b1ca.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0414\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u044f\u0447\u0435\u0435\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0440\u0430\u0437\u0434\u0435\u043b \u043b\u0438\u0441\u0442\u0430 MergeCells, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043b\u0438\u0441\u0442\u0435 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u043c\u0443 SheetData. \u0417\u0430\u043f\u0438\u0441\u044c MergeCell \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Reference, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u043e\u0434\u044b \u044f\u0447\u0435\u0435\u043a \u043b\u0435\u0432\u043e\u0433\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0438 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043d\u0438\u0436\u043d\u0435\u0433\u043e \u0443\u0433\u043b\u043e\u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c\u044b\u0445 \u044f\u0447\u0435\u0435\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: A1:C3. \u0412\u0430\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0441\u0441\u0438\u0432 MergeCells \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043b \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u044f\u0447\u0435\u0435\u043a, \u0442.\u043a. \u044d\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 xlsx-\u0444\u0430\u0439\u043b\u0430 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430\u0445.<\/p>\n<pre><code>if (colSpan &gt; 1) {    var endCol = Convert.ToChar(columnCode + colSpan - 1);    mergeCells!.AppendChild(new MergeCell    {        Reference = $\"{columnCode}{row.RowIndex}:{endCol}{row.RowIndex}\"    });    for (var i = 1; i &lt; colSpan; i++)    {        columnCode++;        cellCode = $\"{columnCode}{rowCounter}\";        row.Append(new Cell { CellReference = cellCode, StyleIndex = styleId });    } }<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u0432\u0441\u0435 \u044f\u0447\u0435\u0439\u043a\u0438, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d, \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043f\u0443\u0441\u0442\u044b\u043c\u0438. \u0411\u0435\u0437 \u043d\u0438\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0438. <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u043e\u0440\u043c\u0443\u043b<\/h3>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0435\u043a \u0440\u0430\u0441\u0447\u0451\u0442\u043d\u044b\u043c\u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u0430\u043c\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Cell.CellValue \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e Cell.CellFormula. \u041e\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0444\u043e\u0440\u043c\u0443\u043b\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>var sumCell = CreateCell(itemRow, cellIdx, basicStyle with { HorizontalAlignment = HorizontalAlignmentValues.Center, NumFormatId = DecimalFormatId }); sumCell.CellFormula = new CellFormula($\"{cntCell.CellReference}*{priceCell.CellReference}\");<\/code><\/pre>\n<p>\u0438\u043b\u0438<\/p>\n<pre><code>var totalCountCell = CreateCell(totalsRow, 3, totalsStyle with { NumFormatId = IntFormatId }); totalCountCell.CellFormula = new CellFormula($\"SUM(D{totalsRow.RowIndex! - order.Items.Length}:D{totalsRow.RowIndex! - 1})\");<\/code><\/pre>\n<p>\u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0447\u0435\u0439\u043a\u0438, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0422\u0438\u043f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0442\u0438\u043b\u0435\u0439<\/h3>\n<p>\u0421\u0442\u0438\u043b\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c zip-\u0430\u0440\u0445\u0438\u0432\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 StylesheetPart. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u0438\u043b\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0448\u0440\u0438\u0444\u0442\u0430, \u0437\u0430\u043b\u0438\u0432\u043a\u0438, \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u044f\u0447\u0435\u0439\u043a\u0438. \u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0441\u0442\u0438\u043b\u0435\u0439 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u041f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 \u0441\u0442\u0438\u043b\u044f \u043a \u044f\u0447\u0435\u0439\u043a\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 StyleId, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0432\u043d\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0441\u0442\u0438\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<pre><code>var styleId = FindOrAppendStyle(styleParams); cell.StyleIndex = styleId;<\/code><\/pre>\n<p>\u0421\u0430\u043c\u0438 \u0441\u0442\u0438\u043b\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 AppendTextStyle. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u0438\u043f \u0437\u0430\u043f\u0438\u0441\u0438 StyleParams, \u043f\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0441\u0442\u0438\u043b\u0435\u0439. \u0412 StyleParams \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0441\u0442\u0438\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0445 \u0438\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<pre><code>private record StyleParams {    public string FontFamily { get; set; }       public int FontSize { get; set; }     public bool Bold { get; set; }       public string Fill { get; set; }       public HorizontalAlignmentValues HorizontalAlignment { get; set; }       public uint? NumFormatId { get; set; } }  private uint AppendTextStyle(SpreadsheetDocument document, StyleParams styleParams) {    var stylesheet = document.WorkbookPart.WorkbookStylesPart.Stylesheet;    stylesheet.Fonts.AppendChild(new Font    {        FontName = new FontName { Val = styleParams.FontFamily },        FontSize = new FontSize { Val = styleParams.FontSize },        Bold = new Bold { Val = styleParams.Bold }    });       var fontId = stylesheet.Fonts.Count++;    var fillId = 0u;       var border = new Border();    border.Append(new LeftBorder { Style = BorderStyleValues.Thin, Color = new Color { Rgb = \"000000\" } });    border.Append(new RightBorder { Style = BorderStyleValues.Thin, Color = new Color { Rgb = \"000000\" } });    border.Append(new TopBorder { Style = BorderStyleValues.Thin, Color = new Color { Rgb = \"000000\" } });    border.Append(new BottomBorder { Style = BorderStyleValues.Thin, Color = new Color { Rgb = \"000000\" } });    stylesheet.Borders.AppendChild(border);    var borderId = stylesheet.Borders.Count++;      if (!string.IsNullOrEmpty(styleParams.Fill))    {        stylesheet.Fills.AppendChild(new Fill        {            PatternFill = new PatternFill            {                PatternType = PatternValues.Solid, ForegroundColor = new ForegroundColor                {                    Rgb = styleParams.Fill                }            }        });         fillId = stylesheet.Fills.Count++;    }    var alignment = new Alignment    {        Horizontal = styleParams.HorizontalAlignment,        Vertical = VerticalAlignmentValues.Center,        WrapText = true    };       stylesheet.CellFormats.AppendChild(new CellFormat    {        BorderId = borderId,        ApplyBorder = true,        FillId = fillId,        ApplyFill = true,        FontId = fontId,        ApplyFont = true,        NumberFormatId = styleParams.NumFormatId,        ApplyNumberFormat = true,        Alignment = alignment,        ApplyAlignment = true    });    return stylesheet.CellFormats.Count++; }<\/code><\/pre>\n<p>\u0412\u00a0\u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b\u00a0\u0432\u0435\u0437\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u043d\u044b\u0435 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u044f\u0447\u0435\u0435\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0441\u0442\u0438\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0440\u0430\u043d\u0438\u0446. \u0412\u00a0\u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u044b (\u043b\u0435\u0432\u043e\/\u043f\u0440\u0430\u0432\u043e\/\u0432\u0435\u0440\u0445\/\u043d\u0438\u0437), \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0446\u0432\u0435\u0442, \u0442\u043e\u043b\u0449\u0438\u043d\u0430 \u0438\u00a0\u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0433\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u044f\u0447\u0435\u0435\u043a<\/h3>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb1\/48e\/91d\/eb148e91d7905ce63e586fa12c7e2455.png\" width=\"400\" height=\"499\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/eb1\/48e\/91d\/eb148e91d7905ce63e586fa12c7e2455.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb1\/48e\/91d\/eb148e91d7905ce63e586fa12c7e2455.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e \u0432\u044b\u0448\u0435, \u0444\u043e\u0440\u043c\u0430\u0442 \u044f\u0447\u0435\u0439\u043a\u0438 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0435\u0434\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432.<\/p>\n<pre><code>stylesPart.Stylesheet.NumberingFormats = new NumberingFormats(    new NumberingFormat { NumberFormatId = IntFormatId, FormatCode = \"#\" },    new NumberingFormat { NumberFormatId = DecimalFormatId, FormatCode = \"#.00\" },    new NumberingFormat { NumberFormatId = DateFormatId, FormatCode = \"dd.mm.yyyy\" });<\/code><\/pre>\n<p>\u0421\u0430\u043c\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0438\u043b\u0435, \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u043c \u043a \u044f\u0447\u0435\u0439\u043a\u0435.<\/p>\n<pre><code>stylesheet.CellFormats.AppendChild(new CellFormat {    NumberFormatId = styleParams.NumFormatId, });<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u044f\u0447\u0435\u0439\u043a\u0438, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d \u0441\u0442\u0438\u043b\u044c \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>numCell.DataType = CellValues.Number;<\/code><\/pre>\n<p>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 OpenXml \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0432\u043e\u0439 \u044f\u0437\u044b\u043a \u043c\u0430\u0441\u043e\u043a \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0447\u0438\u0441\u0435\u043b \u0438 \u0434\u0430\u0442, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0438\u0441\u043b\u043e \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0443 \u0447\u0438\u0441\u0435\u043b, \u0441\u0438\u043c\u0432\u043e\u043b\u044b-\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0438 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432, \u0438\u043b\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u0442. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0442 \u044f\u0437\u044b\u043a \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b-\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0443 \u0447\u0438\u0441\u0435\u043b.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0435\u0447\u0430\u0442\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b xlsx. \u041a\u043e\u0434 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0435\u0449\u0451 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u043b\u0443\u0447\u0448\u0435\u043d \u0432 \u0447\u0430\u0441\u0442\u0438 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0436\u0435 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0431\u044b\u043b \u043e\u0442\u0434\u0430\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0435 \u043a\u043e\u0434\u0430 \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 xlsx, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0435\u043a \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0443\u043b. \u0421 API \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446 xlsx \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e <a href=\"https:\/\/github.com\/alrodov\/XlsxPrintExample\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>. \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043d\u0430\u0448 \u0446\u0438\u043a\u043b \u043e\u0431\u0437\u043e\u0440\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u00ab\u043e\u0444\u0438\u0441\u043d\u044b\u0445\u00bb \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0432 .NET.<\/p>\n<p>\u041c\u044b\u00a0\u0432\u00a0\u00ab\u0411\u0410\u0420\u0421 \u0413\u0440\u0443\u043f\u00bb \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0433\u043e\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0430, \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0438\u00a0\u043b\u044e\u0434\u0435\u0439. \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u041d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u00ab\u0426\u0438\u0444\u0440\u043e\u0432\u0430\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043a\u0430\u00bb \u0438\u00a0\u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0437\u0430\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u201488\u00a0\u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432\u00a0\u0440\u0435\u0435\u0441\u0442\u0440\u0435 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u041f\u041e. \u0420\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u00a0\u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u0445 \u0438\u00a0\u0418\u0422-\u0442\u0440\u0435\u043d\u0434\u0430\u0445 <a href=\"https:\/\/t.me\/barsgroup_public\" rel=\"noopener noreferrer nofollow\">\u0432\u00a0Telegram-\u043a\u0430\u043d\u0430\u043b\u0435<\/a>. \u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u0435\u0447\u0430\u0442\u0438 <a href=\"https:\/\/sprinter.ost-digital.ru\/\" rel=\"noopener noreferrer nofollow\">Sprinter<\/a>\u00a0\u2014 \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442, \u0443\u0436\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u00a0\u0440\u0435\u0435\u0441\u0442\u0440. \u041e\u043d\u00a0\u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438\u00a0\u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c \u0441\u00a0\u043f\u0435\u0447\u0430\u0442\u044c\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u00a0\u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c. \u0410\u00a0\u0435\u0449\u0451 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0443\u0432\u0438\u0434\u0435\u043b\u0430 \u0441\u0432\u0435\u0442 \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/918798\/\"> https:\/\/habr.com\/ru\/articles\/918798\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u042f \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u0420\u043e\u0434\u043e\u0432, \u0432\u0435\u0434\u0443\u0449\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u00ab\u0411\u0410\u0420\u0421 \u0413\u0440\u0443\u043f\u00bb, \u0430\u0432\u0442\u043e\u0440 \u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0447\u0430\u0442\u043d\u044b\u0445 \u0444\u043e\u0440\u043c Sprinter. \u042d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0451\u0439 \u043c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a DocumentFormat.OpenXml \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0447\u0430\u0442\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u00ab\u043e\u0444\u0438\u0441\u043d\u044b\u0445\u00bb \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/barsgroup\/articles\/893810\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/barsgroup\/articles\/900920\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0442\u043e\u0440\u043e\u0439<\/a> \u0447\u0430\u0441\u0442\u044f\u0445 \u0440\u0435\u0447\u044c \u0448\u043b\u0430 \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0435\u0447\u0430\u0442\u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e \u0437\u0430\u043a\u0430\u0437\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 docx. \u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0435\u0447\u0430\u0442\u0438 xlsx, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u041f\u041e \u043d\u0435 \u0440\u0435\u0436\u0435, \u0430, \u0431\u044b\u0442\u044c \u043c\u043e\u0436\u0435\u0442, \u0434\u0430\u0436\u0435 \u0447\u0430\u0449\u0435, \u0447\u0435\u043c docx. \u042d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u0430\u044e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0443 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0435\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u0445 \u0441\u0442\u0438\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0444\u043e\u0440\u043c\u0443\u043b \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"\"><\/figure>\n<h3>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0442\u0443 \u0436\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0438 \u0442\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0437\u0430\u043a\u0430\u0437\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043e\u043d\u043b\u0430\u0439\u043d-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 xlsx-\u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u00a0\u0437\u0430\u043a\u0430\u0437\u0430. \u0421\u0442\u043e\u043b\u0431\u0435\u0446\u00a0F (\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043d\u044b\u043c: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u00a0\u044f\u0447\u0435\u0439\u043a\u0430\u0445 \u0440\u0430\u0432\u043d\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u00a0\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u00a0\u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0442\u043e\u0432\u0430\u0440\u0430. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u043d\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0432\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445\u00a0D \u0438\u00a0F\u00a0\u2014 \u0441\u0443\u043c\u043c\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u00a0\u044d\u0442\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445. \u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0435\u043a \u0438\u00a0\u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u00a0\u044f\u0447\u0435\u0439\u043a\u0430\u0445.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430<\/h3>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 docx, xlsx-\u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 (Parts), \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0445 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0438\u043b\u0438, \u043c\u0435\u0434\u0438\u0430\u0444\u0430\u0439\u043b\u044b, \u0438 \u0442.\u0434. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0434\u0440\u0443\u0433\u0438\u0435 \u0436\u0435 \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code>private const int IntFormatId = 101; private const int DecimalFormatId = 102; private const int DateFormatId = 103; public async Task&lt;MemoryStream&gt; Print(PurchaseOrder order) {    var stream = new MemoryStream();    using var document = InitDocument(stream, order);    PrintPurchase(document, order);    document.Save();    return stream; } private SpreadsheetDocument InitDocument(MemoryStream stream, PurchaseOrder order) {    var doc = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook, true);    var workbookPart = doc.AddWorkbookPart();    workbookPart.Workbook = new Workbook();    #region \u0440\u0430\u0437\u0434\u0435\u043b \u0441\u0442\u0438\u043b\u0435\u0439    var stylesPart = workbookPart.AddNewPart&lt;WorkbookStylesPart&gt;();    stylesPart.Stylesheet = new Stylesheet    {        Fonts = new Fonts { Count = 1 },        Fills = new Fills { Count = 2 },        Borders = new Borders { Count = 1 },        CellFormats = new CellFormats { Count = 1 }    };    stylesPart.Stylesheet.Fonts.AppendChild(new Font());    stylesPart.Stylesheet.Fills.AppendChild(new Fill { PatternFill = new PatternFill { PatternType = PatternValues.None } });    stylesPart.Stylesheet.Fills.AppendChild(new Fill { PatternFill = new PatternFill { PatternType = PatternValues.Gray125 } });    stylesPart.Stylesheet.Borders.AppendChild(new Border());    stylesPart.Stylesheet.CellFormats.AppendChild(new CellFormat());    stylesPart.Stylesheet.NumberingFormats = new NumberingFormats(        new NumberingFormat { NumberFormatId = IntFormatId, FormatCode = \"#\" },        new NumberingFormat { NumberFormatId = DecimalFormatId, FormatCode = \"#.00\" },        new NumberingFormat { NumberFormatId = DateFormatId, FormatCode = \"dd.mm.yyyy\" });     #endregion    #region \u043e\u0431\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438    var sharedStringTablePart = workbookPart.AddNewPart&lt;SharedStringTablePart&gt;();    sharedStringTablePart.SharedStringTable = new SharedStringTable();       #endregion       #region \u0422\u0435\u043b\u043e \u0438 \u043b\u0438\u0441\u0442\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430       var currentSheetsCount = workbookPart!.WorksheetParts.Count();       var worksheetPart = workbookPart.AddNewPart&lt;WorksheetPart&gt;();    worksheetPart.Worksheet = new Worksheet();     worksheetPart.Worksheet.AppendChild(new Columns());    worksheetPart.Worksheet.AppendChild(new SheetData());    worksheetPart.Worksheet.AppendChild(new MergeCells());     var sheets = workbookPart.Workbook.GetFirstChild&lt;Sheets&gt;();    if (sheets == null)    {        sheets = workbookPart.Workbook.AppendChild(new Sheets());    }     sheets.Append(new Sheet    {        Name = $\"\u0417\u0430\u043a\u0430\u0437 \u2116{order.PurchaseNumber}\",        Id = workbookPart.GetIdOfPart(worksheetPart),        SheetId = (uint)currentSheetsCount + 1    });    #endregion    return doc; }<\/code><\/pre>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 Stylesheet.NumberingFormats. \u042d\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u0442, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0446\u0435\u043b\u044b\u0445 \u0438 \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0421\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043d\u0438\u0445 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u044f\u0447\u0435\u0439\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 InitDocument \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 (\u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439) \u043b\u0438\u0441\u0442 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u0438\u043c\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0437\u0430\u043a\u0430\u0437\u0430 \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u00a0\u043b\u0438\u0441\u0442 Excel \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0415\u0434\u0438\u043d\u0438\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u00a0\u2014 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b excel, \u0440\u0430\u0432\u043d\u044b\u0435 7\u00a0\u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c \u043f\u0440\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 dpi=96.<\/p>\n<pre><code>private float CmToExcelCharacters(float cmSize) {    return cmSize \/ 2.54f * 96 \/ 7; }  private void PrintPurchase(SpreadsheetDocument document, PurchaseOrder order) {    #region \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043b\u0438\u0441\u0442\u0430       var rowCounter = 0u;    var worksheet = document.WorkbookPart!.WorksheetParts.First().Worksheet;    var sheet = worksheet.GetFirstChild&lt;SheetData&gt;()!;    var mergeCells = worksheet.GetFirstChild&lt;MergeCells&gt;();    var columns = worksheet.GetFirstChild&lt;Columns&gt;();     var stylesDict = new Dictionary&lt;StyleParams, uint&gt;();     columns.Append(        new Column { Min = 1, Max = 1, Width = CmToExcelCharacters(1), CustomWidth = true },        new Column { Min = 2, Max = 2, Width = CmToExcelCharacters(2), CustomWidth = true },        new Column { Min = 3, Max = 3, Width = CmToExcelCharacters(5), CustomWidth = true },        new Column { Min = 4, Max = 4, Width = CmToExcelCharacters(2.2f), CustomWidth = true },        new Column { Min = 5, Max = 5, Width = CmToExcelCharacters(2), CustomWidth = true },        new Column { Min = 6, Max = 6, Width = CmToExcelCharacters(2), CustomWidth = true });     #endregion    \/\/ ... }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0448\u0430\u043f\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041e\u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b\u00a0\u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u0432\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u043e\u0431\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a (SharedStrings) \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430. \u0412\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u044f\u0447\u0435\u0435\u043a \u0431\u0443\u0434\u0443\u0442 \u0434\u0430\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430\u00a0\u044d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e\u00a0\u0438\u0445\u00a0\u0438\u043d\u0434\u0435\u043a\u0441\u0443 \u0432\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0435, \u0430\u00a0\u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044f\u0447\u0435\u0439\u043a\u0438\u00a0\u2014 \u00ab\u043e\u0431\u0449\u0438\u0439\u00bb. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0432\u00a0xlsx\u00a0\u2014 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0415\u0433\u043e \u043c\u044b\u00a0\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u00a0\u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<p>\u0412\u00a0\u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435 \u043d\u0438\u0436\u0435, \u043f\u043e\u043c\u0438\u043c\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0448\u0430\u043f\u043a\u0438, \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0441\u0442\u0438\u043b\u0435\u0439 \u044f\u0447\u0435\u0435\u043a. \u0414\u0435\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e\u00a0\u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u0432\u00a0xlsx \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0438\u0436\u0435 \u0432\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<pre><code>\/\/\/ &lt;summary&gt; \/\/\/ \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \/\/\/ &lt;\/summary&gt; private int AppendSharedString(SpreadsheetDocument document, string sharedString) {    OpenXmlElement siContent;    var textEl = new Text(sharedString) { Space = SpaceProcessingModeValues.Preserve };    siContent = textEl;    var sharedStringTablePart = document.WorkbookPart!.GetPartsOfType&lt;SharedStringTablePart&gt;().Single();    sharedStringTablePart.SharedStringTable.AppendChild(new SharedStringItem(siContent));     return sharedStringTablePart.SharedStringTable.ChildElements.Count - 1; } private void PrintPurchase(SpreadsheetDocument document, PurchaseOrder order) {     \/\/ ...    #region \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0448\u0430\u043f\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430       var titleStyle = basicStyle with { FontSize = 12, Bold = true };    AddTextRow($\"\u0417\u0430\u043a\u0430\u0437 \u2116{order.PurchaseNumber} \u043e\u0442 {order.PurchaseDate.ToLongDateString()}\", titleStyle);    AddTextRow($\"\u041a\u043b\u0438\u0435\u043d\u0442: {order.CustomerName}\", titleStyle);    AddTextRow($\"\u0410\u0434\u0440\u0435\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438: {order.CustomerAddress}\", titleStyle);     var tableHeaderStyle = basicStyle with { Bold = true, Fill = \"DDDDDD\" };    AddTextRow($\"\u0421\u043e\u0441\u0442\u0430\u0432 \u0437\u0430\u043a\u0430\u0437\u0430\", tableHeaderStyle with { FontSize = 12, HorizontalAlignment = HorizontalAlignmentValues.Center });       var tableTitlesRow = GetNextRow();    var tableTitles = new[] { \"\u2116\", \"\u041a\u043e\u0434\", \"\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435\", \"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\", \"\u0426\u0435\u043d\u0430\", \"\u0421\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c\" };    var cellIdx = 0;       foreach (var title in tableTitles)    {        var cell = CreateCell(tableTitlesRow, cellIdx++, tableHeaderStyle);        cell.CellValue = new CellValue(AppendSharedString(document, title));        cell.DataType = CellValues.SharedString;    }    #endregion     \/\/ ...    Row GetNextRow()    {        var r = new Row { RowIndex = ++rowCounter };        sheet.Append(r);         return r;    }    Cell CreateCell(Row row, int cellIndex, StyleParams styleParams, uint colSpan = 1)    {        var columnCode = Convert.ToChar('A' + cellIndex % 26);        var cellCode = $\"{columnCode}{rowCounter}\";        var cell = new Cell { CellReference = cellCode };         var styleId = FindOrAppendStyle(styleParams);        cell.StyleIndex = styleId;        row.Append(cell);        if (colSpan &gt; 1)        {            var endCol = Convert.ToChar(columnCode + colSpan - 1);            mergeCells!.AppendChild(new MergeCell            {                Reference = $\"{columnCode}{row.RowIndex}:{endCol}{row.RowIndex}\"            });            for (var i = 1; i &lt; colSpan; i++)            {                columnCode++;                cellCode = $\"{columnCode}{rowCounter}\";                row.Append(new Cell { CellReference = cellCode, StyleIndex = styleId });            }        }        return cell;    }    void AddTextRow(string text, StyleParams styleParams)    {        var textRow = GetNextRow();        var textCell = CreateCell(textRow, 0, styleParams, 6);        textCell.CellValue = new CellValue(text);        textCell.DataType = CellValues.String;    }    uint FindOrAppendStyle(StyleParams styleParams)    {        if (!stylesDict.TryGetValue(styleParams, out var styleId))        {            styleId = stylesDict[styleParams] = AppendTextStyle(document, styleParams);        }         return styleId;    } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-463559","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=463559"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463559\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}