【问题标题】:How to prettify the json text in the Excel cell?如何美化Excel单元格中的json文本?
【发布时间】:2023-01-10 15:50:33
【问题描述】:

在excel文件中,有很多像下面这样的json文本

{"component":"{{$labels.component}}","container":"{{$labels.container}}","daemonset":"{{$labels.daemonset}}","directory":"{{$labels.directory}}","figure":"{{$value}}","instance":"{{$labels.instance}}","job":"{{$labels.job}}","name":"{{$labels.name}}","namespace":"{{$labels.namespace}}","pod":"{{$labels.pod}}","reason":"{{$labels.reason}}"}

我想像这样美化 json 文本

{
 "component": "{{$labels.component}}",
 "container": "{{$labels.container}}",
 "daemonset": "{{$labels.daemonset}}",
 "directory": "{{$labels.directory}}",
 "figure": "{{$value}}",
 "instance": "{{$labels.instance}}",
 "job": "{{$labels.job}}",
 "name": "{{$labels.name}}",
 "namespace": "{{$labels.namespace}}",
 "pod": "{{$labels.pod}}",
 "reason": "{{$labels.reason}}"
}

有没有办法对我的 excel 文件中的任何单元格执行此操作?
谢谢!

【问题讨论】:

    标签: json excel


    【解决方案1】:

    如果您有 Excel 365 当前频道,那么您可以使用此公式 - 您的 json 在单元格 A1

    =LET(json,A1,
         r,SUBSTITUTE(json,",","," & CHAR(10)),
        "{" & CHAR(10) & MID(r,3,LEN( r)-3) & CHAR(10) & "}")
    

    首先,它将逗号替换为逗号加换行符 char(10)。然后它处理第一个和最后一个换行符。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      相关资源
      最近更新 更多