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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.03.2010, 03:18   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
All Lables from given Layer in given Languages
Источник: http://alexvoy.blogspot.com/2010/03/...-in-given.html
==============

Sometimes I need to see a label translations into different languages. Sometimes it is good to see all the labels that were created during the project on a given layer - like those on USR.

This job exports all labels from a given layer in given languages to an Excel file.


Here I used the two following code examples from the AXForum.info:


Firstly, the job calculates the number of labels; then, it shows progress window; finally, it opens an Excel file saved under the name like "Labels from "+#LayerId+ " in "+#English+", "+#French+", "+#Russian+".xls".


In this particular job are SYS layer and three mentioned languages used; you can easily change them to your needs.


X++:
static void SisPrintAllLabelsOnGivenLanguages(Args _args)
{
    // needed layer
    #define.LayerId("SIS")
    // all needed languages
    #define.English("en-us")
    #define.French("fr-ca")
    #define.Russian("ru")
    // label classes
    Label   lEn = new Label(#English);
    Label   lFr = new Label(#French);
    Label   lRu = new Label(#Russian);
    // start looking every label
    str 250 lId;
    int totalLabels;
    RunbaseProgress         progress;
    #macrolib.AviFiles
    //Excel variables section
    COM rstAxa = new COM('ADODB.Recordset');    // ADO: Recordset
    COM flds   = rstAxa.Fields();
    COM fld;
    #define.LabelId("LabelId")
    COM xlApp;            
    COM wbks, wbk;        
    COM wkss, wks;        
    COM rng, cell, rngCR; 
    COM font;             
    COM entCol;           
    COM actWin;           
    int i, iMax;
    ;
    print("@SYS34745");
    // start looking every label
    lId = lEn.searchFirst('');
    while (lId)
    {
        if (lEn.moduleId(lId) == #LayerId) // The particular label file
        {
            // count labels
            totalLabels++;
        }
        lId = lEn.searchNext();
    }
    print(strfmt("%1 = %2", "@SYS54695", totalLabels));
    print("@SYS76178");
    if (totalLabels<=0)
        return;

    progress = RunbaseProgress::construct(1,null);

    progress.setCaption("@SYS76178");
    progress.setTotal(totalLabels);
    progress.setAnimation(#AviPrint);

    // <--- create excel fields in a worksheet
    flds.Append(#LabelId, 8);
    flds.Append(#English, 8);
    flds.Append(#French, 8);
    flds.Append(#Russian, 8);
    rstAxa.Open();

    xlApp = new COM('Excel.Application');
    xlApp.Visible(false);
    wbks = xlApp.Workbooks();
    wbk  = wbks.Add();
    wkss = wbk.Worksheets();
    wks  = wkss.Item(1);
    wks.Name("Labels");
    rng  = wks.Range('A1');
    flds = rstAxa.Fields();
    iMax = flds.Count() - 1;
    for (i = 0; i <= iMax; i += 1)
    {
        fld = flds.Item(i);
        cell = rng.Offset(0, i);
        cell.Value2(fld.Name());
    }
    rngCR = rng.CurrentRegion();
    font = rngCR.Font();
    font.Bold(true);
    cell = rng.Offset(1, 0);
    // <--- end of creating of excel fields in a worksheet

    lId = lEn.searchFirst('');
    while (lId)
    {
        if (lEn.moduleId(lId) == #LayerId) // The particular label file
        {
            // print to excel
            progress.incCount();
            rstAxa.AddNew();
            fld = flds.Item(#LabelId);  fld.Value(lId);
            fld = flds.Item(#English);  fld.Value(lEn.extractString(lId));
            fld = flds.Item(#French);   fld.Value(lFr.extractString(lId));
            fld = flds.Item(#Russian);  fld.Value(lRu.extractString(lId));
            rstAxa.Update();
        }
        lId = lEn.searchNext();
    }
    cell.CopyFromRecordset(rstAxa);
    progress.kill();
    // format excel worksheet
    rngCR = rng.CurrentRegion();
    entCol = rngCR.EntireColumn();
    entCol.AutoFit();
    cell.Select();
    actWin = xlApp.ActiveWindow();
    actWin.FreezePanes(true);
    rstAxa.Close();
    xlApp.Visible(true);
    wbk.SaveAs("Labels from "+#LayerId+ " in "+#English+", "+#French+", "+#Russian+".xls");
}
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Layer codes from license file or from DB kop DAX in English 5 30.11.2009 15:56
mfp: Building a layer file from XPO files Blog bot DAX Blogs 0 13.11.2006 22:30
Dynamics AX Geek: Deleting all objects from a custom layer Blog bot DAX Blogs 0 28.10.2006 16:40
Вопрос про Demand Planner slava09 DAX: Функционал 4 25.09.2006 11:43
Говорят вышел SP2 для Axapta 3. Кто нибуть что знает на эту тему? soin DAX: Прочие вопросы 10 13.10.2003 10:43
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 01:04.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.