zoukankan      html  css  js  c++  java
  • D365做文件导入导出CSV

    1.在环境中,大家可以参考类LedgerConsolidate;

    2.流文件的导入;

    CommaTextStreamIo       commaTextIo;

    container                           trans;

    str                                      value;

    commaTextIo = CommaTextStreamIo::constructForRead(File::UseFileFromURL(_filename));

     while (!commaTextIo.status())
    {
           trans= commaTextIo.read();//读取行记录,用容器接收
           value = conpeek(trans,1);//读取容器元素对象
    }

    默认列分隔符为'\,'逗号,行分隔符为' '换行符号,如果有不通,需要特别指定。

    传参数给如下2个方法:

    commaTextIo.inFieldDelimiter(' ');
    commaTextIo.inRecordDelimiter('|');

    这里的filename是指通过文件上传工具File upload control获取 到的文件名,非绝对路径地址。

    对于上传控件大家可以参考官方文档:

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/user-interface/file-upload-control

    3.流文件导出;

    commaTextIo = CommaTextStreamIo::constructForWrite();

    commaTextIo.writeExp([]);

    默认列分隔符为'\,'逗号,行分隔符为' '换行符号,如果有不通,需要特别指定。

    传参数给如下2个方法:

    commaTextIo.outRecordDelimiter(' ');
    commaTextIo.outFieldDelimiter('|');

    4.声明流文件;

    private int codepage()
     {
            #Localcodepage
            return #cp_1252;
    }
    public static StreamIo newFile(int _codepage, StreamType _type = StreamType::AsciiIo)
        {
            StreamIo fileIo;
            switch (_type)
            {
                case StreamType::AsciiIo:
                    fileIo = TextStreamIo::constructForWrite(_codepage);
                    break;
                case StreamType::CommaIo:
                    fileIo = CommaTextStreamIo::constructForWrite(_codepage);
                    break;
                default:
                    throw error ("@SYS62665");
            }
            return fileIo;
        }
  • 相关阅读:
    穷举字符串的一种算法
    使用VirtualBox SDK之初步编译
    Install Shield 中判断安装还是卸载
    [转] win32内核程序中进程的pid,handle,eprocess之间相互转换的方法
    如何做PHD (1)
    在TFS 2010中使用邮件提醒功能(Email Notification)
    Chrome的Awesome Screenshot的插件离线下载
    Visual Studio 2010下生成Crypto++ lib
    VirtualBox开发环境的搭建详解
    VC版PwdHash
  • 原文地址:https://www.cnblogs.com/alfred-cn/p/13097583.html
Copyright © 2011-2022 走看看