Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

If you set PreserveStrings to true, ExcelWriter will preserve numeric strings as strings.

Signature
C#
C#
 public boolean PreserveStrings{ get; set; }
{signature}{signature:
}
Signature
vb.net
vb.net
Public Property PreserveStrings() As Boolean
{signature}
{remarks}
By 
Remarks

By default,

when

populating

template

data

markers,

ExcelWriter

tries

to

convert

numeric

strings

to

numbers.

{{PreserveStrings}} is a *

PreserveStrings is a Read/Write

*

property.

This

property

can

be

set

for

individual

data

markers

using

the

[

Preserve

data

marker

modifier

|Creating Data Markers#modifiers]. {remarks} {example}{code:csharp|title=C#}

.

Example
Code Block
csharp
csharp
titleC#


          ExcelTemplate xlt = new ExcelTemplate();
          xlt.Open(@"C:\DataBinding\ArrayBindingTemplate.xls");
          string[][] twodim = {
               new string[]{"Watertown", "MA", "02472"},
               new string[]{"Washington","DC", "20500"}
               };
          string[] names = {"City", "State", "Zip"};
          xlt.BindData(twodim,
               names,
               "TwoDimArray",
               xlt.CreateDataBindingProperties());
          xlt.PreserveStrings = true;
          xlt.Process();
          xlt.Save(Page.Response, "ArrayBinding.xls", false);
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          Dim xlw As New ExcelTemplate()
          xlt.Open("C:\DataBinding\ArrayBindingTemplate.xls")
          Dim twodim As String()() = { _
               New String(){"Watertown", "MA", "02472"}, _
               New String(){"Washington", "DC", "20500"}, _
               }
          Dim names As String() = {"City", "State", "Zip"}
          xlt.BindData(twodim, _
               names, _
               "TwoDimArray", _
               xlt.CreateDataBindingProperties())
          xlt.PreserveStrings = True
          xlt.Process()
          xlt.Save(Page.Response, "ArrayBinding.xls", False)
        
{code} {example}