Quantcast
Channel: npoi Discussions Rss Feed
Viewing all 637 articles
Browse latest View live

New Post: ICellStyle FillForegroundColor issues

$
0
0
Hi, We are newly started using NPOI components.
We are having issues to set FillForegroundColor of ICellStyle property.

ICellStyle HeaderCellStyle = xssfworkbook.CreateCellStyle();
HeaderCellStyle.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.RED.index;
FillForegroundColor expects of type short.

How do we set a different color rather than using colors in HSSFColor.
We need to set to "#BE4E5E" and how do we do that for ICellStyle property FillForegroundColor

Colud someone help us by some example?

New Post: Basic pre-requisites to use NPOI

$
0
0
Hi,

I am using NPOI for the first time.

I am making an ASP.NET web site where on click of a button, I want to generate an Excel file in a password protected state and send it to the client to download it.

But I want to know whether, will I require MS Excel installed on the server?
OR Is there a way where I can make this work on a server where MS Excel NOT installed?

Also what are other pre-requisites?

New Post: Basic pre-requisites to use NPOI

$
0
0
No. You don't need MS Excel at all. NPOI write binary stream to response or file system. As long as you have .NET 2.0 sp1 installed, it would be enough to run NPOI.

New Post: Excel Data Writer Wrapper in Excel using NPOI

$
0
0
You had better put this in github or somewhere. I don't think discussion will be viewed by a lot of people. Anyway, thank you for what you shared. It looks to be useful.

New Post: How to decrypt Excel 2003-2007 xls file?

$
0
0
it can decrypt xlsx file but can not decrypt 2003-2007 file
How to decrypt Excel 2003-2007 xls file?

New Post: NPOI and setCellFormula(): decimal-separator is cutoff

$
0
0
I found the same problem whith NPOI 2.0.1.

If I use sheet.SetCellFormula("10 * 0.015"), the result is "10 * 15" when the correct is "10 * 1,5".

New Post: NPOI and setCellFormula(): decimal-separator is cutoff

$
0
0
Hi All,

Since 2.0.5 is just released, can you try the latest version? And let me know if it still exists.

New Post: [NPOI.XSSF.UserModel] XLSX file : repair needed when using Double in SetCellValue()

$
0
0
I faced the same problem and narrowed it down a bit.

On my German system with German culture info (i.e. comma as decimal separator), the XML files will be corrupt, regardless of the data type I am trying to write. Diff-ing the worksheet files revealed that this has to do with the basic sheet info being written at the end of the worksheets XML. The code generated on a German machine will be
<pageMargins left="0,7" right="0,7" top="0,75" bottom="0,75" header="0,3" footer="0,3"></pageMargins></worksheet> 
instead of
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"></pageMargins></worksheet> 
Obviously this will throw an error with OpenOffice or Excel.

So I will use a forced US culture info for writing the data streams. This should take care of all file stream issues.

New Post: How to decrypt Excel 2003-2007 xls file?

New Post: How to Insert a Column in a .xls or .xlsx file?

$
0
0
I know there's some way to insert rows. But how to insert columns?
static void InsertRows(ref HSSFSheet sheet1, int fromRowIndex, int rowCount)
        {
            sheet1.ShiftRows(fromRowIndex, sheet1.LastRowNum, rowCount, true, false, true);

            for (int rowIndex = fromRowIndex; rowIndex < fromRowIndex + rowCount; rowIndex++)
            {
                Row rowSource = sheet1.GetRow(rowIndex + rowCount);
                Row rowInsert = sheet1.CreateRow(rowIndex);
                rowInsert.Height = rowSource.Height;
                for (int colIndex = 0; colIndex < rowSource.LastCellNum; colIndex++)
                {
                    Cell cellSource = rowSource.GetCell(colIndex);
                    Cell cellInsert = rowInsert.CreateCell(colIndex);
                    if (cellSource != null)
                    {
                        cellInsert.CellStyle = cellSource.CellStyle;
                    }
                }
            }
        }

New Post: Build samples

$
0
0
Hello.

When I open "NPOI.Examples.2010.sln" and try build it, I had multiple unresolved assembly reference errors. I know that I would be add reference to binary NPOI dll's in a some project samples one-by-one, but Its count is too big in the samples solution.
  1. Can I add reference to all sample projects in solution in one action?
  2. And There is a technique for install binary dlls in system by default?
  3. How is it true technique for install NPOI binary dlls and any other libraries in system?
Sorry of my english and my newbie questions.

Best regards!

New Post: Build samples

$
0
0
foxxxx wrote:
Hello.

When I open "NPOI.Examples.2010.sln" and try build it, I had multiple unresolved assembly reference errors. I know that I would be add reference to binary NPOI dll's in a some project samples one-by-one, but Its count is too big in the samples solution.
  1. Can I add reference to all sample projects in solution in one action?
    I founded that is not capability:
    stackoverflow
Sorry of my english and my newbie questions.

Best regards!

New Post: add pdf stream into worksheet

$
0
0
Hi I have two pdf files. I want to add each pdf file into worksheet.

Is it possible?

Regards,
Alex

New Post: Merge two different excel files into one excel file

$
0
0
Hi,

I I have created two HSSFWorkbook and want to merge these two workbook into one.

May I know how I can merge?

Regards,
Alex

New Post: NPOI 2.0 beta 1 : Copy sheet between workbooks (contributed by Paul Kratt)

$
0
0
Hi,
I saw Copy sheet between workbooks (contributed by Paul Kratt) in NPOI 2.0 beta 1 release.

May I know how I can copy sheet between workbooks.

Regards,
Alex

New Post: How to get image position (Anchor) in excel

$
0
0
Hi,
I have one function call GetVesselUtilizationReportFile and it generate one excel file base on outport. It can be generated successfully. Now I need to generate one excel file for all outports. so I loop through outport by outport, get the byte data, create temp workbook and copy sheet to main workbook. But copyto function does not copy images in sheet. It can only copy text. So that I manually add the image again as per below code. I have hard code the anchor and create the picture. So that I need to know the exact position of current images in excel. May I know how can I get the image position is excel sheet.
foreach (var outport in outports)
            {
                string mimeType;
                string extension;
                byte[] excelStreaming = vesselUtilizationController.GetVesselUtilizationReportFile(DateTime.Now,
                                                                           outport.BusinessUnitId,
                                                                           "excel", out mimeType,
                                                                           out extension);
                // Getting the complete workbook...
                using (Stream stream = new MemoryStream(excelStreaming))
                {
                    var templateWorkbook = new HSSFWorkbook(stream);
                    var hssfSheet = (HSSFSheet)templateWorkbook.GetSheet("VesselUtilizationPrint");
                    hssfSheet.CopyTo(workbook, outport.Code, true, true);
                    
                    var images = templateWorkbook.GetAllPictures();
                    var i = 1;
                    foreach (HSSFPictureData image in images)
                    {
                        var pictureIdx = workbook.AddPicture(image.Data, (PictureType)image.Format);
                        //get sheet
                        var workbookSheet = workbook.GetSheet(outport.Code);
                        // Create the drawing patriarch.  This is the top level container for all shapes. 
                        var drawing = workbookSheet.CreateDrawingPatriarch();
                        //add a picture shape
                        var anchor = helper.CreateClientAnchor();
                        //set top-left corner of the picture,
                        //subsequent call of Picture#resize() will operate relative to it
                        switch (i)
                        {
                            case 1:
                                anchor.Col1 = 3;
                                anchor.Row1 = 2;
                                break;
                            case 2:
                                anchor.Col1 = 19;
                                anchor.Row1 = 2;
                                break;
                            case 3:
                                anchor.Col1 = 2;
                                anchor.Row1 = 8;
                                break;
                        }
                        i++;
                        var pict = drawing.CreatePicture(anchor, pictureIdx);
                        //auto-size picture relative to its top-left corner
                        pict.Resize();
                    }
                }
                
            }
            using(var ms = new MemoryStream())
            {
                // Writing the workbook content to the FileStream...
                workbook.Write(ms);

                // Sending the server processed data back to the user computer...
                var response = HttpContext.Current.Response;
                response.ContentType = "application/vnd.ms-excel";
                response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}", "CrewList.xls"));
                response.Clear();
                response.BinaryWrite(ms.GetBuffer());
                response.End();
            }

New Post: Build samples

$
0
0
You can use Notepad++ and replace all of the relative path of the assembly reference with an absolute path (on your computer) in the csproj file.

New Post: How to Insert a Column in a .xls or .xlsx file?

$
0
0
There is no native API to do that. But you can try to figure out by your own code.

New Post: Build samples

$
0
0
That's a really big stuff to modify every project file...
I found that they use the path (in 20131204 examples package.zip):
..\..\..\solution\Lib\NPOI.dll
So we just create a solution folder and copy our dll files from the binary package into the above path.
Image

(Ionic.Zip.dll can be downloaded from: http://dotnetzip.codeplex.com/)

New Post: How can I obtain Scaling mode: Reduce/Enlarge printout?

$
0
0
Sorry to bother but I'm still swamped. Can someone give a hint?

Thanks!
Viewing all 637 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>