Copies content from the table to the clipboard. Algorithm is a slight
rewrite of the article below.

@see <a href="http://www.copy--paste.org/copy-paste-jtables-excel.htm">http://www.copy--paste.org/copy-paste-jtables-excel.htm</a>
767517
public void copyToClipboard(final int rowIndex, final int colIndex, final int width, final int height) {
        final StringBuilder sb = new StringBuilder();
        if (rowIndex == 0 && colIndex == 0 && width == getColumnCount() && height == getRowCount()) {
            for (int i = 0; i < width; i++) {
                sb.append(getColumnName(i));
                if (i < height - 1) {
                    sb.append("\t");
                }
            }
            sb.append("\n");
        }

        for (int row = rowIndex; row < rowIndex + height; row++) {
            for (int col = colIndex; col < colIndex + width; col++) {
                Object value = getValueAt(row, col);
                if (value == null) {
                    value = "";
                } else if (value instanceof JComponent) {
                    value = WidgetUtils.extractText((JComponent) value);
                }
                sb.append(value);
                sb.append("\t");
            }
            sb.deleteCharAt(sb.length() - 1);
            sb.append("\n");
        }
        final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        final StringSelection stsel = new StringSelection(sb.toString());

        clipboard.setContents(stsel, stsel);
    }
518933
function copyListener (text, e) {
  copySuccess = true
  e.clipboardData.setData(TEXT_PLAIN, text)

  if (e.clipboardData.getData(TEXT_PLAIN) !== text) {
    copySuccess = false
  }
  e.preventDefault()
}
1047132
def _copy_cell_text(self):
        
        txt = self.currentItem().text()
        QtWidgets.QApplication.clipboard().setText(txt)
433715
def write_table(self):
        

        super(TextTableWriter, self).write_table()
        if self.is_write_null_line_after_table:
            self.write_null_line()
263497
private JTable getTableExtension() {
		if (tableExt == null) {
			tableExt = new JTable();
			tableExt.setModel(this.model);
			tableExt.getColumnModel().getColumn(0).setPreferredWidth(30);
			tableExt.getColumnModel().getColumn(1).setPreferredWidth(320);
			tableExt.getColumnModel().getColumn(2).setPreferredWidth(50);
			// Issue 954: Force the JTable cell to auto-save when the focus changes.
			// Example, edit cell, click OK for a panel dialog box, the data will get saved.
			tableExt.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

			// Disable for now - would be useful but had some problems with this ;)
			/*
			ListSelectionListener sl = new ListSelectionListener() {

				@Override
				public void valueChanged(ListSelectionEvent arg0) {
	        		if (tableExt.getSelectedRow() > -1) {
	        			Context ctx = ((ContextListTableModel)tableExt.getModel()).getContext(
	        					tableExt.getSelectedRow());
	        			if (ctx != null) {
	        				try {
								extName.setText(ext.getName());
								extDescription.setText(ext.getDescription());
								if (ext.getAuthor() != null) {
									extAuthor.setText(ext.getAuthor());
								} else {
									extAuthor.setText("");
								}
								if (ext.getURL() != null) {
									extURL.setText(ext.getURL().toString());
									getUrlLaunchButton().setEnabled(true);
								} else {
									extURL.setText("");
									getUrlLaunchButton().setEnabled(false);
								}
							} catch (Exception e) {
								// Just to be safe
								log.error(e.getMessage(), e);
							}
	        			}
	        		}
				}};
			
			tableExt.getSelectionModel().addListSelectionListener(sl);
			tableExt.getColumnModel().getSelectionModel().addListSelectionListener(sl);
			*/
			
		}
		return tableExt;
	}
171661
def copy_path_to_clipboard(self):
        
        path = self.get_current_path()
        QtWidgets.QApplication.clipboard().setText(path)
        debug('path copied: %s' % path)
1104095
def saveToClipboard(sheet, rows, filetype=None):
    ''
    filetype = filetype or options.save_filetype
    vs = copy(sheet)
    vs.rows = rows
    status('copying rows to clipboard')
    clipboard().save(vs, filetype)
1051345
def copy_format(self):
        

        row, col, tab = self.grid.actions.cursor
        code_array = self.grid.code_array

        # Cell attributes

        new_cell_attributes = []
        selection = self.get_selection()
        if not selection:
            # Current cell is chosen for selection
            selection = Selection([], [], [], [], [(row, col)])

        # Format content is shifted so that the top left corner is 0,0
        ((top, left), (bottom, right)) = \
            selection.get_grid_bbox(self.grid.code_array.shape)

        cell_attributes = code_array.cell_attributes
        for __selection, table, attrs in cell_attributes:
            if tab == table:
                new_selection = selection & __selection
                if new_selection:
                    new_shifted_selection = new_selection.shifted(-top, -left)
                    if "merge_area" not in attrs:
                        selection_params = new_shifted_selection.parameters
                        cellattribute = selection_params, table, attrs
                        new_cell_attributes.append(cellattribute)

        # Rows

        shifted_new_row_heights = {}
        for row, table in code_array.row_heights:
            if tab == table and top <= row <= bottom:
                shifted_new_row_heights[row-top, table] = \
                    code_array.row_heights[row, table]

        # Columns

        shifted_new_col_widths = {}
        for col, table in code_array.col_widths:
            if tab == table and left <= col <= right:
                shifted_new_col_widths[col-left, table] = \
                    code_array.col_widths[col, table]

        format_data = {
            "cell_attributes": new_cell_attributes,
            "row_heights": shifted_new_row_heights,
            "col_widths": shifted_new_col_widths,
        }

        attr_string = repr(format_data)

        self.grid.main_window.clipboard.set_clipboard(attr_string)
918967
def paste(self):
        
        html = QApplication.clipboard().text()
        if not self.isRichTextEditEnabled():
            self.insertPlainText(projex.text.toAscii(html))
        else:
            super(XTextEdit, self).paste()
1101149
def _textToTable(self, text, separator='\t'):
        
        table = None
        if text.startswith('[[') or text.startswith('(('):
            try:
                # maybe it's already formated as a list e.g. "[['1','2'],[...]]"
                # check it:
                t = eval(text)
            # has to be a 2d-list:
                if isinstance(t, list) and isinstance(t[0], list):
                    table = t
            except SyntaxError:
                # not a valid list
                pass
        if not table:
            # create the list from the clipboard-text
            # therefore the text has to be formated like this:
                # "1\t2\3\n4\t5\6\n"
            table = text.split('\n')
            n = 0
            while n < len(table):
                sline = table[n].split(separator)
                if sline != ['']:
                    table[n] = sline
                else:
                    table.pop(n)
                    n -= 1
                n += 1
        return table
1037166
def copy_to_clipboard(self, copy=True):
        
        urls = self.selected_urls()
        if not urls:
            return
        mime = self._UrlListMimeData(copy)
        mime.set_list(urls)
        clipboard = QtWidgets.QApplication.clipboard()
        clipboard.setMimeData(mime)
623231
private void copyCellStyle(final Cell fromCell, final Cell toCell) {

        final CellStyle style = fromCell.getCellStyle();
        toCell.setCellStyle(style);
        toCell.setCellType(CellType.BLANK);

        // 横方向に結合されている場合、結合情報のコピーする。（XlsArrayColumns用）
        final Sheet sheet = fromCell.getSheet();
        final CellRangeAddress mergedRegion = POIUtils.getMergedRegion(sheet, fromCell.getRowIndex(), fromCell.getColumnIndex());
        final int mergedSize = POIUtils.getColumnSize(mergedRegion);

        if(POIUtils.getColumnSize(mergedRegion) >= 2) {
            CellRangeAddress newMergedRegion = POIUtils.getMergedRegion(sheet, toCell.getRowIndex(), toCell.getColumnIndex());
            if(newMergedRegion != null) {
                // 既に結合している場合 - 通常はありえない。
                return;
            }

            newMergedRegion = POIUtils.mergeCells(sheet,
                    mergedRegion.getFirstColumn(), toCell.getRowIndex(), mergedRegion.getLastColumn(), toCell.getRowIndex());

            // 結合先のセルの書式も設定する
            // 中間のセルの設定
            for(int i=1; i < mergedSize; i++) {
                Cell mergedFromCell = POIUtils.getCell(sheet, toCell.getColumnIndex()+i, fromCell.getRowIndex());

                Cell mergedToCell = POIUtils.getCell(sheet, toCell.getColumnIndex()+i, toCell.getRowIndex());
                mergedToCell.setCellStyle(mergedFromCell.getCellStyle());
                mergedToCell.setCellType(CellType.BLANK);
            }

        }

    }
250574
@SuppressWarnings({"rawtypes","unchecked"})
    public static void copyRowsToTable(Selection rows, Table oldTable, Table newTable) {
        for (int columnIndex = 0; columnIndex < oldTable.columnCount(); columnIndex++) {
            Column oldColumn = oldTable.column(columnIndex);
            int r = 0;
            for (int i : rows) {
                newTable.column(columnIndex).set(r, oldColumn, i);
                r++;
            }
        }

    }
462590
function(elTable) {
    if(elTable) {
        // Destroy previous
        this._destroyBdTheadEl();

        var elThead = elTable.insertBefore(document.createElement("thead"), elTable.firstChild);
        
        // Add TRs to the THEAD;
        var oColumnSet = this._oColumnSet,
            colTree = oColumnSet.tree,
            elTh, elTheadTr, oColumn, i, j, k, len;

        for(i=0, k=colTree.length; i<k; i++) {
            elTheadTr = elThead.appendChild(document.createElement("tr"));
    
            // ...and create TH cells
            for(j=0, len=colTree[i].length; j<len; j++) {
                oColumn = colTree[i][j];
                elTh = elTheadTr.appendChild(document.createElement("th"));
                this._initBdThEl(elTh,oColumn,i,j);
            }
        }
        this._elBdThead = elThead;
    }
}
695049
public static void appendTable(ParagraphAlignment[] alignment, int rows, int cols, String[][] values, int[]
            rowHeight, int[] colWidth, Map<String, Integer> cellMargins, Map<String, Object> styles) {
        createXwpfDocumentIfNull();
        xwpfDocument.createParagraph();
        XWPFTable table = xwpfDocument.createTable(rows, cols);
        XWPFParagraph paragraph;
        XWPFTableRow row;
        XWPFTableCell cell;
        CTTcPr cellPr;
        XWPFRun run;
        if (Checker.isNotEmpty(cellMargins)) {
            int top = MsUtils.checkInteger(cellMargins.get("top"));
            int left = MsUtils.checkInteger(cellMargins.get("left"));
            int bottom = MsUtils.checkInteger(cellMargins.get("bottom"));
            int right = MsUtils.checkInteger(cellMargins.get("right"));
            table.setCellMargins(top, left, bottom, right);
        }
        int minRow = Math.min(rows, values.length);
        for (int i = 0; i < minRow; i++) {
            row = table.getRow(i);
            int height = i < rowHeight.length ? rowHeight[i] : rowHeight[rowHeight.length - 1];
            row.setHeight(height);
            String[] value = values[i];
            int minCol = Math.min(cols, value.length);
            for (int j = 0; j < minCol; j++) {
                cell = row.getCell(j);
                cellPr = cell.getCTTc().addNewTcPr();
                int width = j < colWidth.length ? colWidth[j] : colWidth[colWidth.length - 1];
                cellPr.addNewTcW().setW(BigInteger.valueOf(width));
                paragraph = cell.getParagraphs().get(0);
                int idx = i * cols + j;
                ParagraphAlignment align = idx < alignment.length ? alignment[idx] : alignment[alignment.length - 1];
                paragraph.setAlignment(align);
                run = paragraph.createRun();
                run.setText(value[j]);
                setStyle(run, styles);
            }
        }
    }
1058421
def paste_clipboard_data(self, data, paste_mode=PasteMode.EMACS, count=1):
        
        assert isinstance(data, ClipboardData)
        assert paste_mode in (PasteMode.VI_BEFORE, PasteMode.VI_AFTER, PasteMode.EMACS)

        before = (paste_mode == PasteMode.VI_BEFORE)
        after = (paste_mode == PasteMode.VI_AFTER)

        if data.type == SelectionType.CHARACTERS:
            if after:
                new_text = (self.text[:self.cursor_position + 1] + data.text * count +
                            self.text[self.cursor_position + 1:])
            else:
                new_text = self.text_before_cursor + data.text * count + self.text_after_cursor

            new_cursor_position = self.cursor_position + len(data.text) * count
            if before:
                new_cursor_position -= 1

        elif data.type == SelectionType.LINES:
            l = self.cursor_position_row
            if before:
                lines = self.lines[:l] + [data.text] * count + self.lines[l:]
                new_text = '\n'.join(lines)
                new_cursor_position = len(''.join(self.lines[:l])) + l
            else:
                lines = self.lines[:l + 1] + [data.text] * count + self.lines[l + 1:]
                new_cursor_position = len(''.join(self.lines[:l + 1])) + l + 1
                new_text = '\n'.join(lines)

        elif data.type == SelectionType.BLOCK:
            lines = self.lines[:]
            start_line = self.cursor_position_row
            start_column = self.cursor_position_col + (0 if before else 1)

            for i, line in enumerate(data.text.split('\n')):
                index = i + start_line
                if index >= len(lines):
                    lines.append('')

                lines[index] = lines[index].ljust(start_column)
                lines[index] = lines[index][:start_column] + line * count + lines[index][start_column:]

            new_text = '\n'.join(lines)
            new_cursor_position = self.cursor_position + (0 if before else 1)

        return Document(text=new_text, cursor_position=new_cursor_position)
1223795
function copyToClipBoard(content) {
  switch (process.platform) {
    case 'darwin': {
      const child = spawn('pbcopy', []);
      child.stdin.end(Buffer.from(content, 'utf8'));
      return true;
    }
    case 'win32': {
      const child = spawn('clip', []);
      child.stdin.end(Buffer.from(content, 'utf8'));
      return true;
    }
    case 'linux': {
      const child = spawn(xsel, ['--clipboard', '--input']);
      child.stdin.end(Buffer.from(content, 'utf8'));
      return true;
    }
    default:
      return false;
  }
}