Я использую VS2008, ASP.net, C# .net, NPOI 1.2.3 dll.экспорт в excel 2003 с одним столбцом с индексом числа indian с использованием NPOI
У меня есть веб-приложение, которое использует NPOI dll для экспорта в excel 2003. Как отображать число с тысячным разделителем в индийском стиле (12, 12,34,567.89) на экспортированном листе excel с использованием программы? Встроенная формула sum() должна применяться к этим экспортированным ячейкам с цифровым форматом.
Заранее спасибо
приведенный ниже код.
защищен недействительным btnGenerateReport_Click (объект отправителя, EventArgs е) { // Получить данные, чтобы сообщить о // вар UserAccounts = Membership.GetAllUsers();
// Create a new workbook and a sheet named "User Accounts"
HSSFWorkbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.CreateSheet("User Accounts");
//var sheet = workbook.CreateSheet("User Accounts");
// Add header labels
int rowIndex = 0;
Row row = sheet.CreateRow(rowIndex);
row.CreateCell(0).SetCellValue("Username");
row.CreateCell(1).SetCellValue("Email");
row.CreateCell(2).SetCellValue("Joined");
row.CreateCell(3).SetCellValue("Last Login");
row.CreateCell(4).SetCellValue("Approved?");
row.CreateCell(5).SetCellValue("Qty");
rowIndex++;
//NUMBER FORMAT BEGIN
CellStyle detailCurrencySubtotalCellStyle = workbook.CreateCellStyle();
detailCurrencySubtotalCellStyle.BorderTop = CellBorderType.THIN;
detailCurrencySubtotalCellStyle.BorderBottom = CellBorderType.THIN;
Font detailCurrencySubtotalFont = workbook.CreateFont();
detailCurrencySubtotalFont.Boldweight = (short)FontBoldWeight.BOLD;
detailCurrencySubtotalCellStyle.SetFont(detailCurrencySubtotalFont);
detailCurrencySubtotalCellStyle.DataFormat = HSSFDataFormat.GetBuiltinFormat("##,##,##,##0.00");
//NUMBER FORMAT END
row = sheet.CreateRow(rowIndex);
row.CreateCell(0).SetCellValue("preejo");
row.CreateCell(1).SetCellValue("[email protected]");
row.CreateCell(2).SetCellValue("01/Jan/2014");
row.CreateCell(3).SetCellValue("27/Jan/2014");
row.CreateCell(4).SetCellValue("true");
//row.CreateCell(5).SetCellValue(((121234567.89).ToString("N", new CultureInfo("hi-IN"))));
//row.CreateCell(5).SetCellValue(Convert.ToDouble(123456.78));
row.CreateCell(5).SetCellValue(123456.78);
//row.GetCell(5).CellStyle = cellStyle;
row.GetCell(5).CellStyle = detailCurrencySubtotalCellStyle;
rowIndex++;
row = sheet.CreateRow(rowIndex);
row.CreateCell(0).SetCellValue("joby");
row.CreateCell(1).SetCellValue("[email protected]");
row.CreateCell(2).SetCellValue("01/Jan/2013");
row.CreateCell(3).SetCellValue("27/Jan/2013");
row.CreateCell(4).SetCellValue("false");
row.CreateCell(5).SetCellValue(Convert.ToDouble(2323313.43));
//row.GetCell(5).CellStyle = cellStyle;
row.GetCell(5).CellStyle = detailCurrencySubtotalCellStyle;
//}
// Auto-size each column
for (int i = 0; i < sheet.GetRow(0).LastCellNum; i++)
sheet.AutoSizeColumn(i);
// Add row indicating date/time report was generated...
sheet.CreateRow(rowIndex + 1).CreateCell(0).SetCellValue("Report generated on " + DateTime.Now.ToString());
//formula
rowIndex++;
row = sheet.CreateRow(rowIndex);
Cell cell = row.CreateCell(5);
cell.SetCellType(CellType.FORMULA);
cell.CellFormula = string.Format("SUM(F{0}:F{1})", 2, 3);
cell.CellStyle = detailCurrencySubtotalCellStyle;
// Save the Excel spreadsheet to a MemoryStream and return it to the client
using (MemoryStream exportData = new MemoryStream())
{
workbook.Write(exportData);
string saveAsFileName = string.Format("MembershipExport-{0:d}.xls", DateTime.Now).Replace("/", "-");
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", saveAsFileName));
Response.Clear();
Response.BinaryWrite(exportData.GetBuffer());
Response.End();
}
}
не будет это вставить номер в виде строки, таким образом, разорвать некоторые функции первенствует после того, как документ импортируется? – CtrlDot