npoi

how I can place an image just in one cell using npoi

末鹿安然 提交于 2019-12-12 07:38:25
问题 I'm using npoi to generate excel docs. I have a requirement to add images to cells. Using the following code i can insert images into my doc. However the image span many cells. How can i ensure that the image just fits inside once cell. public ActionResult NPOICreate() { try { FileStream fs = new FileStream(Server.MapPath(@"\Content\NPOITemplate.xls"), FileMode.Open, FileAccess.ReadWrite); HSSFWorkbook templateWorkbook = new HSSFWorkbook(fs, true); var sheet = templateWorkbook.GetSheet(

When using NPOI which files should I add to Visual Studio in C#

橙三吉。 提交于 2019-12-12 06:37:02
问题 I have been trying to import everything from NPOI but it won´t let me use the library afterwards, so I´m thinking I´m importing the wrong things so if anyone knows that would be great. 回答1: As pointed by Brian in comment to your question. Best way to include all library related to NPOI is NUGet Package Manager. Once it is successfully installed all needed library will appear in reference section of your current project. Then include the NPOI into your file like using NPOI.SS.UserModel; using

Add image to Excel (.xlsx) using NPOI C#

拥有回忆 提交于 2019-12-12 04:32:34
问题 I want to insert image to an XLSX file (not xls) using NPOI. I am using XSSFWorkbook and XSSFSheet byte[] data = File.ReadAllBytes("SomeImage.jpg"); int picInd = workbook.AddPicture(data, XSSFWorkbook.PICTURE_TYPE_JPEG); XSSFCreationHelper helper = workbook.GetCreationHelper() as XSSFCreationHelper; XSSFDrawing drawing = _sheet.CreateDrawingPatriarch() as XSSFDrawing; XSSFClientAnchor anchor = helper.CreateClientAnchor() as XSSFClientAnchor; anchor.Col1 = 1; anchor.Row1 = 1; XSSFPicture pict

why NPOI created cell drop down list always split by comma

我的梦境 提交于 2019-12-12 04:21:57
问题 I use NPOI(the .net version of java - Apache POI) created excel sheet. I need to add some dropdown, but I found no matter what list I passed into it, it always split the item value by comma, thus make a new line. In any chance, do you know how to avoid this happen? Here is my code CellRangeAddressList cellRange = new CellRangeAddressList(cell.RowIndex, cell.RowIndex, cell.ColumnIndex, cell.ColumnIndex); DVConstraint constraint = DVConstraint.CreateExplicitListConstraint(new string[] {"$400","

How to set Validation for a cell in Excel created using NPOI

回眸只為那壹抹淺笑 提交于 2019-12-11 11:39:14
问题 I have created an excell file using NPOI using following code var workbook = new HSSFWorkbook(); var sheet = workbook.CreateSheet("Candidate"); // Add header labels var rowIndex = 0; var row = sheet.CreateRow(rowIndex); row.CreateCell(0).SetCellValue("Name"); row.CreateCell(1).SetCellValue("1,2,3"); row.CreateCell(2).SetCellValue("4,5,6"); row.CreateCell(3).SetCellValue("7,8,9"); rowIndex++; // Add data rows for (int i = 1; i <= 5; i++) { row = sheet.CreateRow(rowIndex); row.CreateCell(0)

Can WCF MemoryStream return type be written to the Http Response object for downloading as an Excel file?

允我心安 提交于 2019-12-11 03:57:24
问题 I built a parsing application that reads xml files and populates an Excel workbook using the NPOI library. Originally, I had that as part of my .net web app and would get the MemoryStream from NPOI and write that to the Response object so the browser would download it. I've since moved the parsing to a WCF netTcp service hosted in a Windows Service. The communication works great, but when I return the MemoryStream from the WCF service and write it to the response, I get the following error:

Formatting error in NPOI

假如想象 提交于 2019-12-11 03:55:03
问题 I'm developing an accountancy software, which will also create a report in Excel format (.xls). I've used NPOI in almost every project that requires an Excel report, without any major problem. But i'm now facing a problem, and can't seem to find any solution browsing the Internet. As you can see, midway the report, the Currency column automatically changes format, not formatting properly currency, border, and everything in that column. I've been working on it for several time, with no success

How to re-calculate a cell's formula?

扶醉桌前 提交于 2019-12-11 02:08:01
问题 My code is setting up a lot cell values. At the end, formulas in every cell needs to be evaluate before the excel file is generated. For most of the sheets, things are going well. However, there is a cell that is throwing an exception. That cell is calculating the average of a series of cells that come after it and reference cells in other sheets. I guess that when the first cell is trying to calculate the average, the cells after are not evaluated yet. This is the formula on that cell

NPOI - Writing to file corrupts .xlsx workbook

不打扰是莪最后的温柔 提交于 2019-12-10 17:32:19
问题 I have a piece of code that is currently writes to a .xls workbook ( HSSFWorkbook ) with no issue. However when I try to use the same code to write to a .xlsx workbook ( XSSFWorkbook ) the archive becomes corrupted and cannot be opened in excel. The following code is what I am using to access the workbook, edit the workbook, and then save back to the workbook. I originally assumed that the code that I was using to edit the workbook was the issue, but after commenting it out the issue still

Insert Image to Excel File Using NPOI

回眸只為那壹抹淺笑 提交于 2019-12-10 15:13:46
问题 I'm writing a program in Visual Studio 2010 using C#, and I'm using the NPOI library. I'm trying to insert an image to the excel file. I tried 2 different methods and neither of them works. //Method 1 HSSFPatriarch patriarch = newSheet.CreateDrawingPatriarch() as HSSFPatriarch; HSSFClientAnchor anchor; var memoryStream = new MemoryStream(); System.Drawing.Image image = System.Drawing.Image.FromFile("image.jpeg"); image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif); anchor = new