Click here to Skip to main content
15,907,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI every one,


i am copying data from listview and pasting it in excel it is pasting.but instead of excel.I want to paste in open office excel(calc).for first time copying data from listview it was working fine.but if you copy second time and paste it in open office it is not pasting.but same thing you can paste in excel it is pasting.how to resolve this please any one tell me.here is my code.

C#
 StringBuilder buffer = new StringBuilder();

 for (int i = 0; i < lv.Columns.Count; i++)
 {
    buffer.Append(lv.Columns[i].Text);
    buffer.Append("\t");
 }

 buffer.Append("\n");

 for (int i = 0; i < lv.Items.Count; i++)
 {
    buffer.Append(lv.Items[i].SubItems[0].Text);
    buffer.Append("\t");
    buffer.Append(lv.Items[i].SubItems[1].Text);
    buffer.Append("\t");
    buffer.Append(lv.Items[i].SubItems[2].Text);
//}

  buffer.Append("\n");

  Clipboard.SetDataObject(buffer.ToString();


thanking you.
Posted
Updated 9-Jan-14 6:29am
v3
Comments
CHill60 9-Jan-14 13:08pm    
Try putting Clipboard.Clear(); before the .SetDataObject - I have a vague recollection that this will overcome an intermittent problem with the clipboard
Bitto kumar 10-Jan-14 4:14am    
I tired but it is not working...thanks for reply
Bitto kumar 10-Jan-14 9:04am    
Please give me any suggestion.....
CHill60 10-Jan-14 11:29am    
Try separating the data items with commas instead of tabs and use Clipboard.SetData(DataFormats.CommaSeparatedValue, buffer) ... you might need to fiddle with buffer e.g. buffer.ToString() or (object)buffer - I can't check this at the moment
Bitto kumar 11-Jan-14 4:12am    
i tired what you said.but in open office paste option is not visible.but in buffer has data..and i tried with all format's still it is not pasting..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900