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

New Post: Sheet.PrintSetup.Scale not working

$
0
0
Hi,

I tried using Sheet.PrintSetup.Scale with 1.2.5 and even with the beta released yesterday, it doesn't seem to change the page setup settings in Excel.

Am I missing something?

Thanks.

New Post: [XSS] XLSX file : repair needed when using Double in SetCellValue()

$
0
0
Hi,

i'm experiencing the same Problem. As soon as I export a double value, the file seems to get corrupted. I also noticed, that the value is then inserted as text, not as a number. Which means I get the little green icon which tells me, that I have stored a number as text.

Please provide a fix for this issue.

Thanks

New Post: Invalid header signature; read 0x2020202020202020, expected 0xE11AB1A1E011CFD0

$
0
0
I have created a excel file using File.WriteAllText(path, strhtml). as it had direct html table. I dont know if there is a way to create a excel file using html with NPOI. once the file is created i have to add an image to another sheet in the file.
I am opeing the excel file using this code.
Dim file As New FileStream(Server.MapPath("~") & "ExternalPerformanceTrend2.xls", FileMode.Open, FileAccess.Read)
but when i pass file to HSSFWorkbook then it gives this error.
hssfworkbook = New HSSFWorkbook(file)

Invalid header signature; read 0x2020202020202020, expected 0xE11AB1A1E011CFD0

New Post: Cell Comments appears to corrupt xls file after creating/adding over 1405

$
0
0
Is there a max number of comments NPIO will support, have created sheets with 32377 comments, but crashes excel on a save. Filtered down the comments, and at 1405 comments added, the file will save, at 1406 comments added, file crashes excel. Comments are over several sheets in the workbook.

The code (cut down)
HSSFPatriarch patr = (HSSFPatriarch)excelSheet.CreateDrawingPatriarch();
//error is class holding position of cell and text
IComment comment = patr.CreateCellComment(new HSSFClientAnchor(0, 0, 0, 0, error.Column, error.Row, error.Column + 3, error.Row + 3));
comment.String = new HSSFRichTextString(error.ErrorDescription);
comment.Author = "XXX";
excelCell.CellComment = comment; //excelCell is ICell

New Post: Cell Comments appears to corrupt xls file after creating/adding over 1405

$
0
0
To be honest, you are the first one to ask the maximum comment a xls supports. This is never tested. Can you tell me why there are so many comments in your Excel file?

Maybe we can work around it by some business requirement change.

New Post: Invalid header signature; read 0x2020202020202020, expected 0xE11AB1A1E011CFD0

$
0
0
NPOI is created to create BINARY xls file and OOXML xlsx files. Html is not a supported option in NPOI because Html is plain text, you can totally use StreamWriter to finish the creation of Html.

New Post: [XSS] XLSX file : repair needed when using Double in SetCellValue()

$
0
0
Hi Mukuahya,

Can you narrow down the issue to a Double value which may break the file via SetCellValue? This should be tested in the test cases.

Btw, why do you think this is an XSS attack? XSS attack is about stealing the authentication from a web UI. It's nothing about Excel file export.

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

$
0
0
Easy way to reproduce (SetCellValueInXlsx sample modified to provoque the error) :
using System;
using System.Collections.Generic;
using System.Text;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.IO;

namespace NPOI.Examples.XSSF.SetCellValuesInXlsx
{
    class Program
    {
        static void Main(string[] args)
        {
            IWorkbook workbook = new XSSFWorkbook();
            ISheet sheet1 = workbook.CreateSheet("Sheet1");
            sheet1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");
            int x = 1;
            for (int i = 1; i <= 15; i++)
            {
                IRow row = sheet1.CreateRow(i);
                for (int j = 0; j < 15; j++)
                {
                    //row.CreateCell(j).SetCellValue(x++);
                    Double dRandom = new Random(x++).NextDouble();
                    row.CreateCell(j).SetCellValue(dRandom);
                }
            }
            FileStream sw = File.Create("test.xlsx");
            workbook.Write(sw);
            sw.Close();
        }
    }
}
When one tries to open the result file, Excel 2010 asks for a repair confirmation, and Excel 2003 refuses to open the file.

Sorry for the title, I just realised that I didn't put the whole library name. I naturally refere to the XSSF namespace. I will try to change this title to make things clear for everyone ;)

New Post: Cell Comments appears to corrupt xls file after creating/adding over 1405

$
0
0
The 1406 appears to be a red herring have created and save files with 1273 and 26397 commands. This appears to be a hard bug to tack down to a single create call as the call will work if comments calls before it are disabled.
In answer to your question we are extracting date from an ifc (CAD file) and creating a COBie spread sheet. COBie is a requirement for the construction industry and is a standard templated excel workbook. The comments are indicators to the user that the information (extracted from the ifc file) in a cell is incorrectly formatted, wrong type, not a reference to another sheet etc. Excel appears to have no problem with the comments once the file is recovered or save as an xlsx format.
Have limited comments to 1000 per sheet and the file saves ok once opened in excel but craches with 1050. Don’t think this is the real problem as I have other files that save in excel with over 1050 comments per sheet.

New Post: Applying HTML tags to output

$
0
0
I am using NPOI to write content to an excel file like this:

CreateCell(wb, qandARow, styQuestions, question.QuestionDescription, question.Level);

However some of the question.QuestionDescription contains Html tags like <b></b>.

How can I have these tags applied to the excel file?

for example if question.QuestionDescription = "hello <b>world</b>, hi" it would show up in excel as "hello world, hi"

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

$
0
0
I have the same problem, please provide fix.
BR

New Post: ISheet.AutoSizeColumn throws NullReferenceException when IFont.Boldweight is been set.

$
0
0
In "ApplyFontInXlsx" example, I add two lines
//apply font to "Microsoft Office"
IFont font4 = workbook.CreateFont();
font4.FontHeightInPoints = 12;
font4.Boldweight = (short)FontBoldWeight.NORMAL;   // first line I added
richtext.ApplyFont(0, 16, font4);
.......
cell3.SetCellValue(richtext);
sheet1.AutoSizeColumn(1);                         // second line I added
FileStream sw = File.Create("test.xlsx");
workbook.Write(sw);
sw.Close();
sheet1.AutoSizeColumn(1) throws NullReferenceException.
Without this line "font4.Boldweight = (short)FontBoldWeight.NORMAL;", It's OK.

Stack trace :
於 NPOI.OpenXmlFormats.Spreadsheet.CT_Font.sizeOfBArray()
   於 NPOI.XSSF.UserModel.XSSFRichTextString.SetRunAttributes(CT_Font ctFont, CT_RPrElt pr)
   於 NPOI.XSSF.UserModel.XSSFRichTextString.ApplyFont(Int32 startIndex, Int32 endIndex, IFont font)
   於 NPOI.Examples.XSSF.ApplyFontInXlsx.Program.Main(String[] args) 於 d:\VS.NET\NPOI\2.0.1\examples\xssf\ApplyFontInXlsx\Program.cs: 行 56
   於 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   於 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   於 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   於 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   於 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   於 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   於 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   於 System.Threading.ThreadHelper.ThreadStart()

New Post: Create row and relative formula reference

$
0
0
Hi,

CopyRow function does not update relative references in formulas for the cells in the new row.
Is this a correct behavior or is there something I have not taken into account?
Unless CopyRow update references, is there any good way to solve my problem?

Yours sincerely
Lars

New Post: Convert/Save HSSFWorkbook as XSSFWorkbook

$
0
0
I'd like to know, if there is a way to save a HSSFWorkbook as XSSFWorkbook (and vice versa)
I tried the following, but it's not working:

HSSFWorkbook lXlsWorkbook = new HSSFWorkbook("c:\file.xls");
MemoryStream lMs = new MemoryStream();
lXlsWorkbook.write(lMs);
lMs.Position = 0;
XSSFWorkbook lXlsxWorkbook = new XSSFWorkbook(lMs); // Here the error occurs "wrong header"
FileStream lFs = new FileStream("c:\file.xlsx", FileMode.OpenOrCreate, FileAccess.Write);
lXlsxWorkbook.write(lFs);
lFs.Close();
lMs.Close();

Has someone done this before? Kind regards, Thomas

New Post: Converting Excel XSL to XSLX (Office 2003 to Offiece 2007)

$
0
0
Hi all! Is there a way to convert Excel XSL to XSLX using NPOI? If you have any informaton, I'll be very appreciate!!! Thanks in advance

New Post: Convert/Save HSSFWorkbook as XSSFWorkbook

$
0
0
Hi. I'm also very interested in this question. Please, someone! Help!!! :-)

New Post: Add pictures to exists Excel file with pictures

$
0
0
Tony, how would I go about checking my version? I am having a very similar issue.

Thanks,
Carl

New Post: No XSSFRow.IsHidden?

$
0
0
Dear NG,
I was just trying to change my Excel output from HSSF to XSSF but noticed, that XSSFRow.IsHidden doesn't seem to exist. How will I make a row hidden in XSSFWorkbook?

Kind regards, Thomas

New Post: No XSSFRow.IsHidden?

$
0
0
Ok, having a close look at the examples reveals the solution. Instead of using XSSFRow.IsHidden = true; I just needed to use use the property XSSFRow.ZeroHeight = true;

New Post: AutoSizeColumn got slow in NPOI 2.0

$
0
0
Dear NG,
I was wondering if anyone experienced a significant slow down when using ISheet.AutoSizeColumn. I have a sheet with 70 columns by 2000 rows. The process of auto-sizing all columns incresed from about 1s for all columns to ~0.3-0.5 seconds for each column. Any idea how to circumvent this problem?
Kind regards, Thomas
Viewing all 637 articles
Browse latest View live


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