Domanda

Sometimes we create class properties with Excel concatenation to speed development. When we copy and paste the rows into Visual Studio, though, each cell's value is within quotes. How do we prevent the quoting of concatenated cells? Here is an example of the output of the paste. Even pasting from Excel into SO puts quotes around each cell's value.

This is an example of the first row of the excel spreadsheet:

A1: bool
B1: System.Boolean
C1: =CONCATENATE("/// <summary>", CHAR(10), " /// ", B1, CHAR(10), " /// </summary>", CHAR(10), "[EnumMember]", CHAR(10), PROPER( A1), ",")

This is what gets pasted into Visual Studio:

"/// <summary>
 /// System.Boolean
 /// </summary>
[EnumMember]
Bool,"
"/// <summary>
 /// System.Byte
 /// </summary>
[EnumMember]
Byte,"
"/// <summary>
 /// System.SByte
 /// </summary>
[EnumMember]
Sbyte,"
"/// <summary>
 /// System.Char
 /// </summary>
[EnumMember]
Char,"
"/// <summary>
 /// System.Decimal
 /// </summary>
[EnumMember]
Decimal,"
"/// <summary>
 /// System.Double
 /// </summary>
[EnumMember]
Double,"
"/// <summary>
 /// System.Single
 /// </summary>
[EnumMember]
Float,"
"/// <summary>
 /// System.Int32
 /// </summary>
[EnumMember]
Int,"
"/// <summary>
 /// System.UInt32
 /// </summary>
[EnumMember]
Uint,"
"/// <summary>
 /// System.Int64
 /// </summary>
[EnumMember]
Long,"
"/// <summary>
 /// System.UInt64
 /// </summary>
[EnumMember]
Ulong,"
"/// <summary>
 /// System.Object
 /// </summary>
[EnumMember]
Object,"
"/// <summary>
 /// System.Int16
 /// </summary>
[EnumMember]
Short,"
"/// <summary>
 /// System.UInt16
 /// </summary>
[EnumMember]
Ushort,"
"/// <summary>
 /// System.String
 /// </summary>
[EnumMember]
String,"

We ended up just doing a find-replace on quotes after the paste. That said, how do we paste without the quotes?

È stato utile?

Soluzione

Solution

D1: =CLEAN(C1)

Sample result (Paste Excel to SO)

/// <summary> /// System.Boolean /// </summary>[EnumMember]Bool,

Syntax and explanation

CLEAN(text)
Removes all nonprintable characters from text.

PS : this is tried and tested on Excel 2010, I am afraid this removes chart(10) as well

Altri suggerimenti

So, I'm doing the same excel trick to build a large class. I bumped into this: http://www.dslreports.com/forum/r20193718-Excel-Clipboard-is-adding-quotation-marks

Essentially:

  1. copy your property/comments column from excel
  2. paste your formatted code into MS Word
  3. copy it from Word to your class file

Feels like there should be a way to copy without the quotes but this got it done...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top