Home > Net >  C # winfrom NOPI
C # winfrom NOPI

Time:03-31

Import Excel 10 1 m or so pictures use time is too long

CodePudding user response:

There was a warning
add images

CodePudding user response:

Your upper limit of this error is an array, namely the byte array you define small and can be a your photos to define the size of the array

CodePudding user response:

refer to the second floor singularity code farmers reply:
your upper limit of this error is an array, which is the byte array you define small and can be a your photos to define the size of the array

I am quoted VS download NOPI expand trace code location this how to change

CodePudding user response:

Add a breakpoint is monotonous

CodePudding user response:

Error your image size is 293888, you define a try so the size of the array

CodePudding user response:

reference 5 floor singularity code farmers reply:
add a breakpoint drab once

 
Using NPOI. HSSF. UserModel;
Using NPOI. SS. UserModel;
Using System. Data. SQLite;

Private void Form1_Load (object sender, EventArgs e)
{
HSSFWorkbook workbook=new HSSFWorkbook ();
ISheet sheet1=workbook. CreateSheet (" sheet1 ");
Sheet1. SetColumnWidth (0, 21 * 256);
Sheet1. SetColumnWidth (1, 12 * 256);
Sheet1. SetColumnWidth (3, 15 * 256);

IRow rowHeader=sheet1. CreateRow (0);//create a header row
RowHeader. CreateCell (0, CellType. String). SetCellValue (" photo ID ");
RowHeader. CreateCell (1, CellType. String). SetCellValue (" image ");
HSSFPatriarch patriarch=(HSSFPatriarch) sheet1. CreateDrawingPatriarch ();
For (int I=1; I<=5; I++)
{
IRow row=sheet1. CreateRow (I);
Row. CreateCell (0, CellType. String). SetCellValue (I);
SetPic (workbook, patriarch, "D: \ \ 123. PNG," sheet1, I, 1);
}
Var path="D:/a.x ls";
Using (System. IO Stream Stream=System. IO. File. OpenWrite (path))
{
Workbook. Write (stream);
}
}
Private void setPic (HSSFWorkbook workbook, HSSFPatriarch patriarch, string path, ISheet sheet, int rowline, int col)
{
If (string. IsNullOrEmpty (path)) return;
Byte [] bytes=System. IO. File. ReadAllBytes (@ path);
Int pictureIdx=workbook. AddPicture (bytes, PictureType. JPEG);
//the location of the photograph HSSFClientAnchor (starting cell x offset, start cell y offset, end cell x offset, the end of the cell y offset, columns, rows)
HSSFClientAnchor anchor=new HSSFClientAnchor (70, 10, 0, 0, col, rowline, col + 1, rowline + 1);
//the images into the corresponding location
HSSFPicture Pict=(HSSFPicture) patriarch. CreatePicture (anchor, pictureIdx);
}



This is the code I upload pictures inside have no way can set the size of the

Upload pictures directly crashed a 3 m
  •  Tags:  
  • C#
  • Related