|
![]() |
#1 |
Участник
|
Предлагаю попробовать переписать методы заменив вызовы COM на CLR.
Пример кода создающий csv файл: X++: protected FileName excel2csv(FileName _excelFileName) { Microsoft.Office.Interop.Excel._Application excel; Microsoft.Office.Interop.Excel.Workbooks workbooks; Microsoft.Office.Interop.Excel._Workbook workbook; System.Type type; System.Reflection.FieldInfo fieldInfo; System.Object missing; Microsoft.Office.Interop.Excel.XlFileFormat fileFormat; Microsoft.Office.Interop.Excel.XlSaveAsAccessMode saveAsAccessMode; FileName textFileName; FileName path; FileName name; FileName extention; ; new InteropPermission(InteropKind::ClrInterop).assert(); [path, name, extention] = fileNameSplit(_excelFileName); textFileName = path + name + '.csv'; if (System.IO.File::Exists(textFileName)) System.IO.File::Delete(textFileName); type = System.Type::GetType('System.Reflection.Missing'); fieldInfo = type.GetField('Value'); missing = fieldInfo.GetValue(null); fileFormat = ClrInterop::parseClrEnum('Microsoft.Office.Interop.Excel.XlFileFormat', 'xlTextWindows'); saveAsAccessMode = ClrInterop::parseClrEnum('Microsoft.Office.Interop.Excel.XlSaveAsAccessMode', 'xlNoChange'); excel = new Microsoft.Office.Interop.Excel.ApplicationClass(); workbooks = excel.get_Workbooks(); workbook = workbooks._Open(_excelFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); workbook.SaveAs(textFileName, fileFormat, missing, missing, missing, missing, saveAsAccessMode, missing, missing, missing, missing, missing); workbook.Close(false, _excelFileName, null); CodeAccessPermission::revertAssert(); return textFileName; } |
|
|
За это сообщение автора поблагодарили: Logger (4), gl00mie (5), Batuev Artem (0). |
![]() |
#2 |
Участник
|
|
|
![]() |
#3 |
Участник
|
Цитата:
Procedure - Reference a New Assembly in the AOT Use the following procedure to reference a new assembly in the AOT: 1. Right-click AOT > References. 2. Select Add Reference. 3. The Add Reference form appears. 4. The Add reference form contains all the assemblies that have been registered in the Global Assembly Cache (GAC). However, you are not restricted to just these assemblies. Click the Browse… button to select an assembly from another location. |
|
|
За это сообщение автора поблагодарили: Zabr (4). |
![]() |
#4 |
Участник
|
Тут вопрос возник, какой вообще смысл в такой операции. Внутренее то все равно будет работать COM
Т.е. методы COM заменяются на те же методы COM, которые вызываются не прямо, а через еще одно звено в виде CLR. Или я где-то не прав? |
|
![]() |
#5 |
Участник
|
Цитата:
У всех так ? Может надо что-то ещё вызывать для завершения работы с Excel.
__________________
Дмитрий |
|
Теги |
.net, ax2009, ax4.0, com-объект, excel, импорт данных, импорт файла |
|
|