npoi


Issue downloading .xlsm document with activex controls using NPOI

十年热恋 提交于 2020-01-06 15:52:50
问题 I am trying to implement an excel file download functionality in my asp.net MVC application and using NPOI. The file has three sheets and Sheet2 has two activex buttons. I am reading the source file, adding values to sheet2, save it in temporary location and download the file later using the following code. using (var fs = new FileStream(xlsFilePath, FileMode.Open, FileAccess.Read)) { var templateWorkbook = new XSSFWorkbook(fs); //Sheet update operation done here fs.Close(); var memoryStream

Issue downloading .xlsm document with activex controls using NPOI

ぃ、小莉子 提交于 2020-01-06 15:52:08
问题 I am trying to implement an excel file download functionality in my asp.net MVC application and using NPOI. The file has three sheets and Sheet2 has two activex buttons. I am reading the source file, adding values to sheet2, save it in temporary location and download the file later using the following code. using (var fs = new FileStream(xlsFilePath, FileMode.Open, FileAccess.Read)) { var templateWorkbook = new XSSFWorkbook(fs); //Sheet update operation done here fs.Close(); var memoryStream

Using NPOI, how do I return a cell value as it has been formatted by Excel?

混江龙づ霸主 提交于 2020-01-03 16:49:56
问题 Using NPOI, is there any buildin possibility to format a cell value (especially numeric and date values) as it has been formatted by Excel? If not what would be the best way to implement it? I thought of a formatstring converter from Excel-formatstrings to C#-formatstrings? The following example assumes the Excel-formatstring and the C#-formatstring are the same. So it works for some basic formatstrings like: "#,##0.00" using NPOI.SS.UserModel; ICell cell = workbook.GetSheet("table1").GetRow

how to save xls file as xlsx file using NPOI c#?

本小妞迷上赌 提交于 2020-01-03 08:36:31
问题 I'm using NPOI to open XLS file, then add some modifications to the XLS file. at the end i want to save it as XLSX file. i'm using this code to save it as XLS file: using (var fs = new FileStream(Name, FileMode.Create, FileAccess.Write)) { wb.Write(fs); } Is it possible to save this XLS file as XLSX file using NPOI in C# ? Thanks in advance for your response 回答1: It is possible in general, but not quite easy, rather it is significantly complicated task. XLS file format is handled by

How to set “AutoSize” to Excel sheet column? (NPOI)

别说谁变了你拦得住时间么 提交于 2019-12-30 17:26:13
问题 According to How can columns be set to 'autosize' in Excel documents created with NPOI? I did so: foreach (DataColumn column in dataTable.Columns) { int rowIndex = 0; foreach (DataRow row in dataTable.Rows) { HSSFRow dataRow = sheet.CreateRow(rowIndex); dataRow.CreateCell(column.Ordinal).SetCellValue(row[column].ToString()); rowIndex++; } sheet.AutoSizeColumn(column.Ordinal); } But it doesn't work. How to do right? 回答1: Here is some code that is working for me, using your loops: HSSFWorkbook

Convert xlsx file to xls using NPOI in c#

坚强是说给别人听的谎言 提交于 2019-12-30 11:27:13
问题 I've a excel file in *.xlsx format. I want convert this file into *.xls format in my MVC Web application. In my application hosted server there is no Microsoft.Office package. Please let me know how we can achieve it in NPOI with c#. Thanks in advance. 回答1: I found the solution based on the Andy's suggestion. Here is the source code which is customized to convert XLSX to XLS. public static class ConvertXLSXToXLS { public static HSSFWorkbook ConvertWorkbookXSSFToHSSF(XSSFWorkbook source) { /

Trying to edit cell value of existing Excel file using NPOI

安稳与你 提交于 2019-12-29 09:02:11
问题 I have written the following code to edit an Excel file using C# and NPOI library. There are no errors, but after running the code if I open the file, the value of the cell is not edited. What am I doing wrong? namespace Project37 { class Class1 { public static void Main() { string pathSource = @"C:\Users\mvmurthy\Downloads\VOExportTemplate.xlsx"; FileStream fs = new FileStream(pathSource, FileMode.Open, FileAccess.ReadWrite); HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs, true);

npoi SetCellFormula custom formula in VBA

限于喜欢 提交于 2019-12-25 07:04:23
问题 I have an application that fills with data an excel template .Template is .xlsm .In template I created vba function called SumByColor when i try to set a cell formula to this function i get this error : {"Name 'SumByColor' is completely unknown in the current workbook"} I set formula like this : sheet.GetRow(rowIndex).GetCell(startPos + 2).SetCellFormula(string.Format("SumByColor($AQ$7,F{0}:AI{0})",rowIndex+1)); 来源: https://stackoverflow.com/questions/25077009/npoi-setcellformula-custom

NPOI Page Breaks

↘锁芯ラ 提交于 2019-12-25 01:55:58
问题 I am using the NPOI framework to generate a 97/2003 Excel workbook. I need to set a page break every 44 rows and from the example provided in the framework download, the code to do this is: sheet.SetRowBreak(int row) I can verify these are setting a collection of row integers but when opening the document and viewing the Page Break preview, there is but a single page that encompasses the entire worksheet. Sample Code below: for(int rowCount = 0; rowCount < MaxRows; rowCount += 44) { worksheet

NPOI export excel all columns but last become blank

我怕爱的太早我们不能终老 提交于 2019-12-24 10:44:32
问题 I am investing the AutoSizeColumn() of NPOI Excel exporting. From this SO question, I know that when exporting a DataTable to excel, have to write all data inside one column before calling the AutoSizeColumn() . Example: (as from this SO answer: HSSFWorkbook spreadsheet = new HSSFWorkbook(); DataSet results = GetSalesDataFromDatabase(); //here, we must insert at least one sheet to the workbook. otherwise, Excel will say 'data lost in file' HSSFSheet sheet1 = spreadsheet.CreateSheet("Sheet1");

工具导航Map