Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now the template file is done. Next is writing the code to bind the string value to the data marker.

Writing the code

Code Block
languagecsharp


using SoftArtisans.OfficeWriter.ExcelWriter;
ExcelTemplate oXLT = new ExcelTemplate();
oXLT.Open(Page.MapPath("Hello World.xlsx"));
DataBindingProperties oDataProps = oXLT.CreateDataBindingProperties();
string value = DataValueBox.Text.Trim();
oXLT.BindCellData(value, "DataValue", oDataProps);
oXLT.Process();
oXLT.Save(Page.Response, "Output.xlsx", false);

This section refers to the code-behind for the ExcelTemplate Hello World sample: ExcelTemplate_HelloWorld.aspx.[cs/vb]. The corresponding web form is ExcelTemplate_HelloWorld.aspx.

...

Congratulations, you have completed Hello World for ExcelTemplate!

Final Product

Code Block
languagecsharp


using SoftArtisans.OfficeWriter.ExcelWriter;
ExcelTemplate oXLT = new ExcelTemplate();
oXLT.Open(Page.MapPath("Hello World.xlsx"));
DataBindingProperties oDataProps = oXLT.CreateDataBindingProperties();
string value = DataValueBox.Text.Trim();
oXLT.BindCellData(value, "DataValue", oDataProps);
oXLT.Process();
oXLT.Save(Page.Response, "Output.xlsx", false);