# Copy paste perspective table

**URL:** <https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 24, 2023, 3:01pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825 "2023-04-24T15:01:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![indenkleefj](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/indenkleefj/32/10961_2.png) [@indenkleefj](https://forum.inductiveautomation.com/u/indenkleefj)\
**Post date:** [April 24, 2023, 3:01pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/1 "2023-04-24T15:01:43Z")

</div>

When using the copy function of a perspective table it will copy the JSON of a row.  
When this is pasted in an email, the data isn't shown logically to other people.  
Is there a way to make the copy function copy the data and transform it to a table format that works for an email (or Word document for example).

---

<div class="post-metadata">

**Author:** ![kyler.kamyszek](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kyler.kamyszek](https://forum.inductiveautomation.com/u/kyler.kamyszek)\
**Post date:** [April 24, 2023, 3:09pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/2 "2023-04-24T15:09:16Z")

</div>

Try exporting the data using this function:  
[https://docs.inductiveautomation.com/display/DOC81/system.dataset.exportExcel](https://docs.inductiveautomation.com/display/DOC81/system.dataset.exportExcel)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 24, 2023, 4:46pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/3 "2023-04-24T16:46:28Z")

</div>

> [@\[IGN-1656\]Perspective Table "Copy" changed from copying CSV to copying JSON?](https://forum.inductiveautomation.com/t/ign-1656-perspective-table-copy-changed-from-copying-csv-to-copying-json/65803/9):
>
> We've got an existing (unfortunately longstanding...) ticket to allow you to switch the 'copy' format between JSON, CSV, and TSV (tab separated values), which Excel will allow you to paste directly. I'm pretty sure it's always been JSON out of Perspective.

Still on the backlog ☹

---

<div class="post-metadata">

**Author:** ![indenkleefj](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/indenkleefj/32/10961_2.png) [@indenkleefj](https://forum.inductiveautomation.com/u/indenkleefj)\
**Post date:** [April 24, 2023, 4:46pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/4 "2023-04-24T16:46:39Z")

</div>

I do get this but I want to use the clipboard instead of exporting.

---

<div class="post-metadata">

**Author:** ![indenkleefj](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/indenkleefj/32/10961_2.png) [@indenkleefj](https://forum.inductiveautomation.com/u/indenkleefj)\
**Post date:** [July 17, 2023, 9:06am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/5 "2023-07-17T09:06:15Z")

</div>

Is there a possibility to create your 'own' copy function with a button?  
Which takes this JSON and transforms it to HTML code and sets this HTML to you're clipboard so you can paste it in Outlook?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 17, 2023, 11:24am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/6 "2023-07-17T11:24:47Z")

</div>

this js injection markdown allows you to copy text to the clipboard. This might require your client to accept clipboard access though. Also requires https and proabbly doesnt work all browsers. only testsed on chrome

you'll have to write the bindings value to something usefull yourself, best to write to a custom component only filled by the button or something. and clear this property after this code so it doesnt accidantly fill up the clipboard when unwanted

```auto
[
  {
    "type": "ia.display.markdown",
    "version": 0,
    "props": {
      "markdown": {
        "escapeHtml": false
      }
    },
    "meta": {
      "name": "Markdown"
    },
    "position": {
      "x": 288,
      "y": 373,
      "height": 200,
      "width": 200
    },
    "custom": {},
    "propConfig": {
      "props.source": {
        "binding": {
          "type": "expr",
          "config": {
            "expression": "{../TextField.props.text}"
          },
          "transforms": [
            {
              "code": "\t\n\tif not value: return \"\"\n\t\n\tcode = \"\"\"<img style='display:none' src='/favicon.ico' onload=\\\"\n\t\tnavigator.clipboard.writeText('\"\"\"+value+\"\"\"');\n\t\t\t\t\n\t\\\"></img>\"\"\".replace(\"\\n\", \"\").replace(\"\\t\", \"\")\n\treturn code\n\t",
              "type": "script"
            }
          ]
        }
      }
    }
  }
]

```

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 26, 2024, 1:54pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/7 "2024-04-26T13:54:21Z")

</div>

Hi @victordcq

I tired below code to copy the text in perspective. but its not copying to clipboard.  
code i have return in button and launched the screen in chrome

```python
value = 'testing'

	code = """
	    <img style='display:none' src='/favicon.ico' onload='navigator.clipboard.writeText("{value}");'></img>
	"""
	
	return code

```

whether i am missing something?

---

<div class="post-metadata">

**Author:** ![Ujwal\_Wankhede](https://avatars.discourse-cdn.com/v4/letter/u/4af34b/32.png) [@Ujwal\_Wankhede](https://forum.inductiveautomation.com/u/Ujwal_Wankhede)\
**Post date:** [April 26, 2024, 2:28pm UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/8 "2024-04-26T14:28:41Z")

</div>

The reference script inject js using markdown. Verify you are also doing same.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/9/8916c05cb6e6a4875256bbc8404e880583ea3142.png)

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 29, 2024, 6:44am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/9 "2024-04-29T06:44:31Z")

</div>

> [@prasath.t](#):
>
> `"{value}"`

Yes this does nothing.  
You also should use the replace on the tab/newlines i use  
Just copy the example

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 29, 2024, 7:11am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/10 "2024-04-29T07:11:50Z")

</div>

For testing purpose i tired your script but its returning null

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/3/e3c7b2bf14559462cf07447e2f0b183bdff7390c.png)

anything wrong?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 29, 2024, 7:18am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/11 "2024-04-29T07:18:07Z")

</div>

the code in my post is to be pasted inside the view, its the markdown component + the binding with the script

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 29, 2024, 7:52am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/12 "2024-04-29T07:52:04Z")

</div>

Ok what i am trying is when user click button i want to copy the text from label that's it.  
can you guide me for this please

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 29, 2024, 8:24am UTC](https://forum.inductiveautomation.com/t/copy-paste-perspective-table/72825/13 "2024-04-29T08:24:32Z")

</div>

> [@victordcq](#):
>
> you'll have to write the bindings value to something usefull yourself, best to write to a custom component only filled by the button or something. and clear this property after this code so it doesnt accidantly fill up the clipboard when unwanted

> [@victordcq](#):
>
> `if not value: return`

Copy the code, directly into the view, this should create the markdown + the binding. Change the binding input to some custom prop.  
Write your value to this custom prop on your button click.  
(Clear the custom prop after, since in the binding it checks there is a value or not, this should stop triggering the js)
