使用Excel.OpenXml.Table

时间:2017-02-09 08:54:43

标签: c# excel openxml openxml-table

使用Excel.OpenXml.Table。

使Excel格式为粗体

代码:

 XLTable objXLTable = new XLTable("TEST");

Row<string> objDataRow = new Row<string>(RowType.Data);



for(int i=0; i< 10 ; i++)
{
         Cell<string> c1 = new Cell<string>("Row number " + i.toString());
         Cell<string> c2 = new Cell<string>("tt" );
         Cell<string> c3 = new Cell<string>("bb " );

         objDataRow.Add(c1);
         objDataRow.Add(c2);
         objDataRow.Add(c3);
}

 objXLTable.Add(objDataRow);

我想让c1单元变粗。我试过了什么:

 Cell<string> c1 = new Cell<string>("Row number " + i.toString(),10);

c1.BoldIndex =10 ;

但没有效果。 C1。风格不存在。任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

要添加单元格值,

将字符串内容添加到SharedStringTable,并将该项目的索引用作

<?php $data = file("your text-file path"); // file() read entire file into array // now your array looks like below:- $array = array('TP-Link|192.168.1.247|CHANNEL 02|warehouse', 'Ruckus|192.168.1.248|CHANNEL 03|entrance'); // comment this array line while using the code $keys = array('name','ip','channel','location'); $final_array = array(); foreach ($array as $ar){ $explode = explode('|',$ar); $final_array[] = array_combine($keys,$explode); } echo "<pre/>";print_r($final_array);

使单元格加粗:

cellvalue.text = index

您可以将其添加到:

StyleIndex = (UInt32Value)1U