导出数据时,如何重命名excel表头列名



如何重命名&通过ImpEx导出数据时,在项目属性旁边添加新列?

我有以下内容:

"#% impex.setTargetFile( ""attributes.csv"" , true );"
insert_update ClassificationAttribute; pk[unique=true]; code ; creationtime; classes

但我想要的,除了代码&creationTime、类及其子类别/子类别的名称代码。目前我只能获得PK。

我希望这些列被重命名,例如:code列被重命名为attribute_code

也许你想在上阅读更多

https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/8bef9530866910148e6cff59d9afa127.html

https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/1c8f5bebdc6e434782ff0cfdb0ca1847.html

https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/8bd9d5bb86691014ba9d95a88ede75f3.html

使用阻抗无法实现这一点,除非您可以使用两个csv,一个对应于分类类别,另一个对应分类类别:

"#% impex.setTargetFile( ""ClassificationAttribute.csv"" , true );"
insert_update ClassificationAttribute; pk[unique=true]; code ; creationtime;classes(&Item)
"#% impex.setTargetFile( ""ClassificationClass.csv"" , true );"
insert_update ClassificationClass;&Item;code;name;supercategories(code)

超级类别是一个列表,类也是一个列表。列表场景的列表不支持在一行impex中。即使这样,也无法使用重命名的属性重新导入数据。

然而,您可以使用自定义版本的excel导出和导入来实现相同的功能,OOTB代码是使用apachePOI实现的。扩展DefaultExcelExportService并覆盖创建自定义导出分类属性。如果需要重新导入,则在扩展DefaultExcelImportService后写入反向逻辑:

public class CustomClassificationExportServiceImpl extends DefaultExcelExportService implements CustomExportService{
public class CustomClassificationImportServiceImpl extends DefaultExcelImportService implements CustomImportService{
  1. 为分类导出创建自定义方法。该方法获取与每个分类对应的类作为列表,并将其转换为一组excel单元格
  2. 创建一个meta excel表,存储实际属性与给定别名属性的映射(如果需要重新导入(
  3. 在DefaultExcelImportService中实现导入的自定义逻辑。这应该使用元数据获取实际属性,将excel列转换为列表等

最新更新