How to find out if the copied text in the Clipboard contains header information? - c#

I have implemented Copy/Paste functionality in my WPF DataGrid. I want to copy text along with the headers. Now in the Paste function, I get the copied text through a ClipboardHelper class that returns me a List of string arrays. I remove the first item in the list because it includes the header information before pasting it in the grid. But when I copy from an Excel sheet I have to paste everything as I won't be copying the headers in excel. So how do I find out if the copied text contains header information / if the copied text is from inside the grid or outside?
List<string[]> rowData = ClipboardHelper.ParseClipboardData();
I have used this property to include headers
ClipboardCopyMode="IncludeHeader"

Related

Add Content menubar form in C#

I want to add content headers export from word file in this way picture in the attach
the word file included headers but i dont know how
[enter image description here(https://i.stack.imgur.com/fNxxI.png)]
I read about CH file but I cant to applied

Tab Delimited Text Copy Paste To Excel

I am generating a block of text via C# Stringbuilder, with appropriately tab-delimited text (new lines, "\t", etc.) and displaying the text within a tag in my web application. If I copy/paste this to Excel, all the text pastes into the first column on the spreadsheet.
If I copy the outerHTML of the block (Chrome) or copy/paste into Notepad++ and THEN paste to Excel, all the data pastes neatly into individual cells - which is the desired outcome of this effort. Can anyone tell me what I need to do in order to be able to copy the text from my application and paste it into Excel, so that the text pastes into individual cells (ie, keeps the tab-delimited format)?
Unfortunately, it appears an extra step is required.
The default behaviour of paste in Excel (& many other applications) is to use the original format of the contents of the clipboard.
Copying from a web application/HTML page will result in the clipboard contents being flagged as HTML. The clipboard contents will have the tab character, but as HTML renders tabs to whitespace (compacting to a single whitespace if there are multiple tabs) - just using control-V will convert the tabs to spaces & the contents will appear in a single cell when pasting into Excel..
You will need to use the "Paste Special" option & select "Unicode text" to retain the tabs. There is no way to set this by default : https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_windows8-mso_365hp/how-to-change-default-paste-behavior-with-ctrl-v/f58da075-8fd5-4c80-a64b-5e71ec8ad38b?auth=1
Copying the outerHTML of Chrome sets the clipboard format to text in the first place, pasting to Notepad++ does paste as text rather than HTML then recopying sets the format to text - which is why these methods work.
I was able to paste to Excel and keep the format by changing the element my text wrote to from a div to textarea. Copy/paste of tsv from textarea to a tab-delimited Excel spreadsheet keeps the data formatted in tabular format when pasted. Thanks all for the help.
Try this ,
Before pasting data set excel's text to column delimiters to space and try to paste your values again.
Old topic but I had this. Need to copy something each day from a programme which outputs to google chrome browser. Whenever it was copied and pasted into excel it was going into 1 cell. Yet if I control all and paste it was ok.
I found you can copy only the lines you want and it will behave as wanted - if you don't drag the cursor all the way down off the page. ie if you highlight down to the last piece of information in the bottom right of screen more carefully, when you past to excel it pastes it as tab separated. Whereas if you drag it right down it pastes it all in 1 cell. Might help someone in the future who has this.
You can use 'text to columns' in Excel to format the data in the way you want it to.
After pasting the data into excel, select the column with your data.
Go to Data - click 'Text to columns'
Choose delimited and hit next
Choose Tab and hit finish.
If you don't want to use this extra step, the following works for Excel 2013:
Go to Home, Paste options and click 'Use text import wizard'
Choose delimited and hit next
Choose Tab and hit finish.

How to save pdf with TextBoxes in ASP.NET

I want to save my gridview in pdf.
The point is that all the cells, except the header row (columns title) and the first column (rows title), have to be PDF textboxes, so once I open the file I can write text inside.
How can I do it?
I have found that it is possibe to create a pdf with textfields but I have not found a way to make them in a specific part of the sheet.
I have tried to do so: Link 1

Copy data from datagrid

I am trying to copy data from a datagrid to an Excel file.
My ClipboardCopyMode is set to 'IncludeHeader'. If I copy & paste multiple rows, the headers show up, but the rows are all empty (no data?). For example if I copy 3 rows and paste it in Excel, it looks like the following:
Header1 Header2 Header3 Header4
.
.
.
(Of course not with the periods, but they are indicating the rows.)
If you are using DataBinding you have to use on your DataGridTemplateColumn
ClipboardContentBinding
to specify which property do you want to copy.

How to get the value of a merged cell?

I am working on a project which has to make pdf report from couple of Excel files. The files should look like this: http://img194.imageshack.us/i/24766860.jpg/ and the pdf should look like this: http://img96.imageshack.us/i/u2ntitled.jpg/ where the location column must have the value of the merged cell in the excel file(B2:E2).
So the difficulty is how to read the merged cell and put its value in the location column.
If that info is not enough I can add the source code. If you want any other info ask I'll give it right away.
Merged cells in excel are read by their first cell address. You should be able to pick up merged cell B2:E2 as B2

Categories