我想在 C# 中使用 Open XML SDK 创建一定数量的复选框。我该怎么做?
例子:
(Checkbox) - Shoes
(Checkbox) - Shirt
复选框数量也有所不同。我正在阅读模板文档,然后进行编辑以返回。到目前为止,我有这样的事情:
string documentText;
using (StreamReader reader ...)
{
documentText = reader.ReadToEnd();
}
string addClothes = "";
Run newCheckBox = GenerateRun();
foreach(var item in ClothesList)
{
addClothes = item.clothing;
//MY DILEMMA
documentText = documentText.Replace("##clothing##", newCheckBox + addClothes + "NewLine");
}
public Run GenerateRun()
{
Run run1 = new Run() { RsidRunProperties = "004C0D9A", RsidRunAddition = "00850FA5" };
FieldCode fieldCode1 = new FieldCode() { Space = SpaceProcessingModeValues.Preserve };
fieldCode1.Text = " FORMCHECKBOX ";
run1.Append(fieldCode1);
return run1;
}