日期:2014-05-17  浏览次数:20470 次

excel导出 org.in2bits.MyXls
excel导出是用 org.in2bits.MyXls 做的,有没有人用过呀?
导出来的时间列 不是正常的格式,而是 ”41092“ 这个在哪里设置格式呀?

------解决方案--------------------

public void Save(string sFilePath)
        {
            XlsDocument xls = new XlsDocument();
            xls.FileName = sFilePath;

            int colIndex = 0;
            int rowIndex = 1;

            Worksheet sheet = xls.Workbook.Worksheets.Add("Sheet1");
            Cells cells = sheet.Cells;

            // 表头
            for (int i = 0; i < _fields.Length; i++)
            {
                if (_dataSource.Columns.Contains(_fields[i]))
                {
                    colIndex++;
                    Cell cellHeader = cells.Add(rowIndex, colIndex, _titles[i]);
                    cellHeader.Font.Bold = true;
                    cellHeader.Font.ColorIndex = 4;
                    cellHeader.HorizontalAlignment = HorizontalAlignments.Left;
                    cellHeader.UseBorder = true;