Home > Net >  EasyUI export Excel document id always shows science counting unit
EasyUI export Excel document id always shows science counting unit

Time:11-06



Find out where the oledata.mso - number - online format method shows the CSS version number is too low can't use

Td label put '/t tried it is no use

Is there a big to recruit

CodePudding user response:

I've never used Easyui, but I know the Excel everywhere should use Excel DLL classes, these classes can be set inside the cell's style, you put a light already exported to I don't know what kind of background do you use an export

CodePudding user response:

Export add symbols' in front of the id card when

CodePudding user response:

Try using the
//in order to avoid the date format is replaced by Excel automatically, so set the format for (@) represents a rate as the text to see 
CellStyle. DataFormat=HSSFDataFormat. GetBuiltinFormat (" @ ");



 using Excel; 
Using System. IO;
Using NPOI. HSSF. UserModel;
Using NPOI. SS. UserModel;
Using NPOI. SS. Util.

# region ToExcel
Public MemoryStream ToExcel (System. Data. DataTable dt, string strFileName)
{
System. IO. MemoryStream ms=new System. IO. MemoryStream ();
LogHelper log=LogHelper. GetInstance ();
Try
{

HSSFWorkbook workbook=new HSSFWorkbook ();
ISheet sheet=workbook. CreateSheet (" Sheet1 ");

ICellStyle HeadercellStyle=workbook. CreateCellStyle ();
HeadercellStyle. BorderBottom=NPOI. SS. UserModel. BorderStyle. Thin;
HeadercellStyle. BorderLeft=NPOI. SS. UserModel. BorderStyle. Thin;
HeadercellStyle. BorderRight=NPOI. SS. UserModel. BorderStyle. Thin;
HeadercellStyle. BorderTop=NPOI. SS. UserModel. BorderStyle. Thin;
HeadercellStyle. Alignment=NPOI. SS. UserModel. HorizontalAlignment. Center;
//font
NPOI. SS. UserModel. IFont headerfont=workbook. CreateFont ();
Headerfont. Boldweight=(short) FontBoldWeight. Bold;
HeadercellStyle. SetFont (headerfont);



//with the column name as the column name
Int icolIndex=0;
IRow headerRow=sheet. CreateRow (0);
Foreach (DataColumn item in dt. The Columns)
{
ICell cell=headerRow. CreateCell (icolIndex);
Cell. SetCellValue (item. ColumnName);
Cell. The CellStyle=HeadercellStyle;
IcolIndex++;
}

ICellStyle cellStyle=workbook. CreateCellStyle ();

//to avoid a date format is replaced by Excel automatically, so set the format for (@) represents a rate as the text to see
CellStyle. DataFormat=HSSFDataFormat. GetBuiltinFormat (" @ ");
CellStyle. BorderBottom=NPOI. SS. UserModel. BorderStyle. Thin;
CellStyle. BorderLeft=NPOI. SS. UserModel. BorderStyle. Thin;
CellStyle. BorderRight=NPOI. SS. UserModel. BorderStyle. Thin;
CellStyle. BorderTop=NPOI. SS. UserModel. BorderStyle. Thin;


NPOI. SS. UserModel. IFont cellfont=workbook. CreateFont ();
Cellfont. Boldweight=(short) FontBoldWeight. Normal;
CellStyle. SetFont (cellfont);




//build content
Int iRowIndex=1;
Int iCellIndex=0;
Foreach (DataRow Rowitem in dt. Rows)
{
IRow DataRow=sheet. CreateRow (iRowIndex);
Foreach (DataColumn Colitem in dt. The Columns)
{

ICell cell=DataRow. CreateCell (iCellIndex);
Cell. SetCellValue (Rowitem [Colitem]. ToString ());
Cell. The CellStyle=CellStyle;
ICellIndex++;
}
ICellIndex=0;
IRowIndex++;
}

The adaptive column width//
For (int I=0; I & lt; IcolIndex; I++)
{
Sheet. AutoSizeColumn (I);
}

//write Excel
Workbook. Write (ms);

}
The catch (Exception ex)
{
The WriteErrorLog (" DataToExcel. Cs - ToExcel - "+ ex. Message. The ToString ());
Return ms;
}

Return ms;
}
# endregion

CodePudding user response:



He is the js combined together using the export data not converted to other formats
  •  Tags:  
  • C#
  • Related