简体   繁体   English

上传Excel文件并保存为CSV到指定路径

[英]Upload Excel File and save it as CSV to a specified path

I'm new to Mendix and need to solve the following:我是 Mendix 的新手,需要解决以下问题:

Users all over the world drop a file (xlsx or xls) onto a web page or select a file through a file dialog.世界各地的用户通过文件对话框将文件(xlsx 或 xls)拖放到 web 页面或 select 文件上。 This file should be stored - converted to CSV - with a self-specified name onto a specified share on an own server.此文件应以自指定的名称存储 - 转换为 CSV - 到自己服务器上的指定共享上。

We've puzzled for hours - but to no avail...我们已经困惑了几个小时 - 但无济于事......

We tried various ExcelImporter-templates, the Export_to_CSV-button and several ready-cooked templates in the hope to understand the principles.我们尝试了各种 ExcelImporter 模板、Export_to_CSV 按钮和几个现成的模板,希望能理解其中的原理。 Besides various obstacles the final problem was to get the file on our own machine.除了各种障碍之外,最后的问题是在我们自己的机器上获取文件。

Is there anybody who can point to the needed widgets and who can explain (sort of a cooking recipie:-) ) how to proceed?有没有人可以指出所需的小部件并且可以解释(有点像烹饪食谱:-))如何进行?

TIA TIA

Where are you expecting the file to end up?您希望文件在哪里结束? By importing or creating the export it automatically makes a file that is stored on your machine, it's a question of how you want to get it out.通过导入或创建导出,它会自动生成一个存储在您机器上的文件,这是您希望如何将其导出的问题。 You can access the files by building a page and having the file manager widget on it, or you could pass it back through the browser by using the 'Download file' activity in your original import/export microflow.您可以通过构建页面并在其上安装文件管理器小部件来访问文件,或者您可以使用原始导入/导出微流程中的“下载文件”活动将其通过浏览器传回。

Then there are options of writing it to a specific directory on your machine or through (s)ftp, which I have seen most often.然后可以选择将其写入您机器上的特定目录或通过(s)ftp,这是我最常看到的。 For ftp you can use this: https://marketplace.mendix.com/link/component/106858对于 ftp,您可以使用: https://marketplace.mendix.com/link/component/106858

If you want to write it to a specific directory on the machine I would recommend a very basic Java action, pass your FileDocument entity into that action.如果您想将其写入机器上的特定目录,我会推荐一个非常基本的 Java 操作,将您的 FileDocument 实体传递到该操作中。 I like apache commons IO, which is in many modules already, then the code would be just this:我喜欢 apache commons IO,它已经在许多模块中,那么代码就是这样:

File outputFile = new File(this.OutputPathParameter + "output.csv");文件 outputFile = new File(this.OutputPathParameter + "output.csv"); FileUtils.copyInputStreamToFile(Core.getFileDocumentContent(this.getContext(), this.FileDocParameter), outputFile); FileUtils.copyInputStreamToFile(Core.getFileDocumentContent(this.getContext(), this.FileDocParameter), outputFile);

Also I would recommend asking Mendix dev questions on forum.mendix.com there are a lot of people on there who very quickly answer your questions.另外,我建议在 forum.mendix.com 上向Mendix开发人员提问,那里有很多人可以很快回答您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM