AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.09.2025, 23:09   #1  
Logger is offline
Logger
Участник
Лучший по профессии 2015
Лучший по профессии 2014
 
3,996 / 3293 (117) ++++++++++
Регистрация: 12.10.2004
Адрес: Москва
Записей в блоге: 2
Цитата:
Сообщение от ice Посмотреть сообщение
Добрый день. Не сохранилось ли примера со вставкой картинки в XmlExcelReport_RU? не поделитесь проектом?
Привет.

Я сам такое не делал. Хотя тут все аналогично как в моем примере с кафкой.
Что-то вопрос популярен. Спрашивают его повторно в личке другие люди.

Мой коллега делал. С его разрешения публикую его вариант

X++:
protected void insertImage_inCell(
      Filename _fileName
    , int     _posX
    , int     _posY
    , int64     _posXOffcet
    , int64     _posYOffcet
    , int64     _width
    , int64     _height
)
{
    #define.EMU_per_pixel(9525)//EMU per pixel(approximately)

    DocumentFormat.OpenXml.Packaging.ImagePart                                      imagePart;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.ShapeProperties                      shapeProperties;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.NonVisualPictureProperties           nonVisualPictureProperties;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.NonVisualDrawingProperties           nonVisualDrawingProperties;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.BlipFill                             blipFill;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.Picture                              picture;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.TwoCellAnchor                        twoCellAnchor;
    DocumentFormat.OpenXml.Drawing.Stretch                                          stretch;
    DocumentFormat.OpenXml.Drawing.Blip                                             blip;
    DocumentFormat.OpenXml.Drawing.Transform2D                                      transform2D;
    DocumentFormat.OpenXml.Drawing.Extents                                          extents;
    DocumentFormat.OpenXml.Drawing.PresetGeometry                                   presetGeometry;
    System.IO.FileStream                                                            fileStream;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.FromMarker                           fromMarker;
    DocumentFormat.OpenXml.Drawing.Spreadsheet.ToMarker                             toMarker;

    void clearNet()
    {
        imagePart                   = null;
        shapeProperties             = null;
        nonVisualPictureProperties  = null;
        nonVisualDrawingProperties  = null;
        blipFill                    = null;
        picture                     = null;
        twoCellAnchor               = null;
        stretch                     = null;
        blip                        = null;
        transform2D                 = null;
        extents                     = null;             
        presetGeometry              = null;
        fromMarker                  = null;
        toMarker                    = null;
    }
    
    picId += picId ? 1000 : 1; //Id начинаем с 1000, на случай, если в книге уже есть картинки

    imagePart = drawingsPart.AddImagePart(DocumentFormat.OpenXml.Packaging.ImagePartType::Png);

    fileStream      = new System.IO.FileStream(_fileName, System.IO.FileMode::Open);
    imagePart.FeedData(fileStream);
    fileStream.Close();
    fileStream.Dispose();
    fileStream = null;
    
    blip = new DocumentFormat.OpenXml.Drawing.Blip();
    blip.set_Embed(new DocumentFormat.OpenXml.StringValue(drawingsPart.GetIdOfPart(imagePart)));
    
    blipFill = new DocumentFormat.OpenXml.Drawing.Spreadsheet.BlipFill();
    blipFill.set_Blip(blip);
    blipFill.set_SourceRectangle(new DocumentFormat.OpenXml.Drawing.SourceRectangle());
     
    stretch = new DocumentFormat.OpenXml.Drawing.Stretch();
    stretch.set_FillRectangle(new DocumentFormat.OpenXml.Drawing.FillRectangle());   
    
    OXML_RU::appendChild(blipFill, stretch);

    extents = new DocumentFormat.OpenXml.Drawing.Extents();
    extents.set_Cx(new DocumentFormat.OpenXml.Int64Value(_width));
    extents.set_Cy(new DocumentFormat.OpenXml.Int64Value(_height));

    transform2D = new DocumentFormat.OpenXml.Drawing.Transform2D();
    transform2D.set_Extents(extents);

    shapeProperties = new DocumentFormat.OpenXml.Drawing.Spreadsheet.ShapeProperties();
    shapeProperties.set_BlackWhiteMode(OXMLExp::getEnumValue(DocumentFormat.OpenXml.Drawing.BlackWhiteModeValues::Auto));
    shapeProperties.set_Transform2D(transform2D);

Последний раз редактировалось Logger; 04.09.2025 в 23:10. Причина: не влезло сообщение - пришлось разбить на несколько
За это сообщение автора поблагодарили: raz (10).
Теги
.net, ado, generic, net

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: When browsing AX 2009 Role Centers, you get an error: An unexpected error has occurred on systems with .NET Framework v4.0 installed Blog bot DAX Blogs 1 28.07.2010 08:24
AX.NET: интеграция .NET-приложений с Аксаптой и (будущие) возможности облачных вычислений gl00mie DAX: Программирование 2 23.04.2010 00:47
jinx: Microsoft Dynamics AX und .NET - Erstellen eines Termins in Outlook Blog bot DAX auf Deutsch 0 03.11.2007 00:33
Inside Dynamics AX 4.0: Working with the .NET Business Connector Blog bot DAX Blogs 0 04.10.2007 05:15
Как при импорте задать значение определенного поля? mvf DAX: Программирование 3 04.05.2005 16:26

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:35.