Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Npoi
提交
0c08215d
N
Npoi
项目概览
int
/
Npoi
9 个月 前同步成功
通知
2
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Npoi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0c08215d
编写于
8月 01, 2023
作者:
T
Tony Qu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/nissl-lab/npoi
上级
f5732888
3665a762
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
142 addition
and
10 deletion
+142
-10
OpenXmlFormats/Spreadsheet/Styles/CT_CellProtection.cs
OpenXmlFormats/Spreadsheet/Styles/CT_CellProtection.cs
+1
-1
main/POIFS/FileSystem/NPOIFSFileSystem.cs
main/POIFS/FileSystem/NPOIFSFileSystem.cs
+2
-2
main/Util/IOUtils.cs
main/Util/IOUtils.cs
+5
-6
ooxml/XSSF/Streaming/SXSSFCell.cs
ooxml/XSSF/Streaming/SXSSFCell.cs
+9
-0
ooxml/XSSF/UserModel/XSSFCellStyle.cs
ooxml/XSSF/UserModel/XSSFCellStyle.cs
+0
-1
testcases/main/HSSF/UserModel/TestHSSFWorkbook.cs
testcases/main/HSSF/UserModel/TestHSSFWorkbook.cs
+7
-0
testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs
testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs
+15
-0
testcases/ooxml/XSSF/UserModel/TestXSSFComment.cs
testcases/ooxml/XSSF/UserModel/TestXSSFComment.cs
+103
-0
testcases/test-data/spreadsheet/738.xlsx
testcases/test-data/spreadsheet/738.xlsx
+0
-0
testcases/test-data/spreadsheet/ATM.xls
testcases/test-data/spreadsheet/ATM.xls
+0
-0
未找到文件。
OpenXmlFormats/Spreadsheet/Styles/CT_CellProtection.cs
浏览文件 @
0c08215d
...
@@ -30,7 +30,7 @@ public static CT_CellProtection Parse(XmlNode node, XmlNamespaceManager namespac
...
@@ -30,7 +30,7 @@ public static CT_CellProtection Parse(XmlNode node, XmlNamespaceManager namespac
if
(
node
==
null
)
if
(
node
==
null
)
return
null
;
return
null
;
CT_CellProtection
ctObj
=
new
CT_CellProtection
();
CT_CellProtection
ctObj
=
new
CT_CellProtection
();
ctObj
.
locked
=
XmlHelper
.
ReadBool
(
node
.
Attributes
[
"locked"
]);
ctObj
.
locked
=
XmlHelper
.
ReadBool
(
node
.
Attributes
[
"locked"
]
,
true
);
ctObj
.
hidden
=
XmlHelper
.
ReadBool
(
node
.
Attributes
[
"hidden"
]);
ctObj
.
hidden
=
XmlHelper
.
ReadBool
(
node
.
Attributes
[
"hidden"
]);
return
ctObj
;
return
ctObj
;
}
}
...
...
main/POIFS/FileSystem/NPOIFSFileSystem.cs
浏览文件 @
0c08215d
...
@@ -310,8 +310,8 @@ public NPOIFSFileSystem(Stream stream)
...
@@ -310,8 +310,8 @@ public NPOIFSFileSystem(Stream stream)
data
.
Write
(
headerBuffer
.
Buffer
);
data
.
Write
(
headerBuffer
.
Buffer
);
data
.
Position
=
headerBuffer
.
Length
;
data
.
Position
=
headerBuffer
.
Length
;
//IOUtils.ReadFully(channel, data);
//IOUtils.ReadFully(channel, data
.Buffer
);
data
.
Position
+=
IOUtils
.
ReadFully
(
channel
,
data
.
Buffer
,
data
.
Position
,
(
int
)
channel
.
Length
);
data
.
Position
+=
IOUtils
.
ReadFully
(
channel
,
data
.
Buffer
,
data
.
Position
,
(
int
)
maxSize
);
success
=
true
;
success
=
true
;
// Turn it into a DataSource
// Turn it into a DataSource
...
...
main/Util/IOUtils.cs
浏览文件 @
0c08215d
...
@@ -178,19 +178,18 @@ public static int ReadFully(Stream stream, byte[] b)
...
@@ -178,19 +178,18 @@ public static int ReadFully(Stream stream, byte[] b)
/// <summary>
/// <summary>
/// Same as the normal InputStream#read(byte[], int, int), but tries to ensure
/// Same as the normal InputStream#read(byte[], int, int), but tries to ensure
/// that the
buffer is filled completely if possible, i.e. b.remaining()
/// that the
entire len number of bytes is read
///
returns 0.
///
/// If the end of file is reached before any bytes are
R
ead, returns -1.
/// If the end of file is reached before any bytes are
r
ead, returns -1.
/// If the end of the file is reached after some bytes are read, returns the
/// If the end of the file is reached after some bytes are read, returns the
/// number of bytes read. If the end of the file isn't reached before the
/// number of bytes read. If the end of the file isn't reached before the
/// buffer has no more remaining capacity, will return the number of bytes
/// buffer has no more remaining capacity, will return len bytes
/// that were read.
/// </summary>
/// </summary>
/// <param name="stream">the stream from which the data is read.</param>
/// <param name="stream">the stream from which the data is read.</param>
/// <param name="b">the buffer into which the data is read.</param>
/// <param name="b">the buffer into which the data is read.</param>
/// <param name="off">the start offset in array b at which the data is written.</param>
/// <param name="off">the start offset in array b at which the data is written.</param>
/// <param name="len">the maximum number of bytes to read.</param>
/// <param name="len">the maximum number of bytes to read.</param>
/// <returns></returns>
/// <returns>
the number of bytes read or -1 if no bytes were read
</returns>
public
static
int
ReadFully
(
Stream
stream
,
byte
[]
b
,
int
off
,
int
len
)
public
static
int
ReadFully
(
Stream
stream
,
byte
[]
b
,
int
off
,
int
len
)
{
{
int
total
=
0
;
int
total
=
0
;
...
...
ooxml/XSSF/Streaming/SXSSFCell.cs
浏览文件 @
0c08215d
...
@@ -418,6 +418,15 @@ public ICell CopyCellTo(int targetIndex)
...
@@ -418,6 +418,15 @@ public ICell CopyCellTo(int targetIndex)
public
void
RemoveCellComment
()
public
void
RemoveCellComment
()
{
{
IComment
comment
=
this
.
CellComment
;
if
(
comment
!=
null
)
{
CellAddress
ref1
=
new
CellAddress
(
RowIndex
,
ColumnIndex
);
XSSFSheet
sh
=
((
SXSSFSheet
)
Sheet
).
_sh
;
sh
.
GetCommentsTable
(
false
).
RemoveComment
(
ref1
);
sh
.
GetVMLDrawing
(
false
).
RemoveCommentShape
(
RowIndex
,
ColumnIndex
);
}
RemoveProperty
(
Property
.
COMMENT
);
RemoveProperty
(
Property
.
COMMENT
);
}
}
...
...
ooxml/XSSF/UserModel/XSSFCellStyle.cs
浏览文件 @
0c08215d
...
@@ -806,7 +806,6 @@ public bool IsLocked
...
@@ -806,7 +806,6 @@ public bool IsLocked
{
{
get
get
{
{
if
(!
_cellXf
.
IsSetProtection
())
if
(!
_cellXf
.
IsSetProtection
())
{
{
return
true
;
return
true
;
...
...
testcases/main/HSSF/UserModel/TestHSSFWorkbook.cs
浏览文件 @
0c08215d
...
@@ -1473,5 +1473,12 @@ public void TestWriteToNewFile()
...
@@ -1473,5 +1473,12 @@ public void TestWriteToNewFile()
Assert
.
AreEqual
(
3
,
wb
.
NumberOfSheets
);
Assert
.
AreEqual
(
3
,
wb
.
NumberOfSheets
);
wb
.
Close
();
wb
.
Close
();
}
}
[
Test
]
public
void
TestBug854
()
{
Assert
.
DoesNotThrow
(()
=>
HSSFTestDataSamples
.
OpenSampleWorkbook
(
"ATM.xls"
));
}
}
}
}
}
testcases/ooxml/XSSF/UserModel/TestXSSFCellStyle.cs
浏览文件 @
0c08215d
...
@@ -724,9 +724,24 @@ public void TestGetSetLocked()
...
@@ -724,9 +724,24 @@ public void TestGetSetLocked()
cellStyle
.
IsLocked
=
(
false
);
cellStyle
.
IsLocked
=
(
false
);
Assert
.
IsFalse
(
cellStyle
.
IsLocked
);
Assert
.
IsFalse
(
cellStyle
.
IsLocked
);
}
}
[
Test
]
public
void
TestBug738
()
{
XSSFWorkbook
wb
=
XSSFTestDataSamples
.
OpenSampleWorkbook
(
"738.xlsx"
);
ISheet
sheet
=
wb
.
GetSheet
(
"Sheet1"
);
IRow
row
=
sheet
.
GetRow
(
0
);
ICell
cell
=
row
.
GetCell
(
0
);
Assert
.
IsTrue
(
cell
.
CellStyle
.
IsLocked
);
cell
.
CellStyle
.
IsLocked
=
true
;
Assert
.
IsTrue
(
cell
.
CellStyle
.
IsLocked
);
Assert
.
IsTrue
(
cell
.
CellStyle
.
IsHidden
);
}
[
Test
]
[
Test
]
public
void
TestGetSetIndent
()
public
void
TestGetSetIndent
()
{
{
Assert
.
AreEqual
((
short
)
0
,
cellStyle
.
Indention
);
Assert
.
AreEqual
((
short
)
0
,
cellStyle
.
Indention
);
cellStyle
.
Indention
=
((
short
)
3
);
cellStyle
.
Indention
=
((
short
)
3
);
Assert
.
AreEqual
((
short
)
3
,
cellStyle
.
Indention
);
Assert
.
AreEqual
((
short
)
3
,
cellStyle
.
Indention
);
...
...
testcases/ooxml/XSSF/UserModel/TestXSSFComment.cs
浏览文件 @
0c08215d
...
@@ -316,6 +316,109 @@ public void Bug57838DeleteRowsWthCommentsBug()
...
@@ -316,6 +316,109 @@ public void Bug57838DeleteRowsWthCommentsBug()
wb
.
Close
();
wb
.
Close
();
}
}
[
Test
]
public
void
TestRemoveXSSFCellComment
()
{
IWorkbook
wb
=
new
XSSFWorkbook
();
try
{
ISheet
sheet
=
wb
.
CreateSheet
();
IRow
row
=
sheet
.
CreateRow
(
1
);
ICell
cell
=
row
.
CreateCell
(
0
);
cell
.
SetCellValue
(
"test"
);
IDrawing
drawing
=
sheet
.
CreateDrawingPatriarch
();
ICreationHelper
factory
=
wb
.
GetCreationHelper
();
// When the comment box is visible, have it show in a 1x3 space
IClientAnchor
anchor
=
factory
.
CreateClientAnchor
();
anchor
.
Col1
=
cell
.
ColumnIndex
;
anchor
.
Col2
=
cell
.
ColumnIndex
+
1
;
anchor
.
Row1
=
row
.
RowNum
;
anchor
.
Row2
=
row
.
RowNum
+
3
;
// Create the comment and set the text+author
IComment
comment
=
drawing
.
CreateCellComment
(
anchor
);
IRichTextString
str
=
factory
.
CreateRichTextString
(
"Hello, World!"
);
comment
.
String
=
str
;
comment
.
Author
=
"Apache POI"
;
cell
.
CellComment
=
comment
;
var
exCellComment
=
sheet
.
GetCellComment
(
new
CellAddress
(
1
,
0
));
Assert
.
IsNotNull
(
exCellComment
);
Assert
.
IsTrue
(
exCellComment
.
String
.
String
.
Equals
(
"Hello, World!"
));
Assert
.
IsTrue
(
exCellComment
.
Author
.
Equals
(
"Apache POI"
));
cell
.
RemoveCellComment
();
exCellComment
=
sheet
.
GetCellComment
(
new
CellAddress
(
1
,
0
));
Assert
.
IsNull
(
exCellComment
);
IComment
newComment
=
drawing
.
CreateCellComment
(
anchor
);
newComment
.
String
=
str
;
newComment
.
Author
=
"Apache POI"
;
cell
.
CellComment
=
newComment
;
exCellComment
=
sheet
.
GetCellComment
(
new
CellAddress
(
1
,
0
));
Assert
.
NotNull
(
exCellComment
);
Assert
.
IsTrue
(
exCellComment
.
String
.
String
.
Equals
(
"Hello, World!"
));
Assert
.
IsTrue
(
exCellComment
.
Author
.
Equals
(
"Apache POI"
));
}
finally
{
wb
.
Close
();
}
}
[
Test
]
public
void
TestRemoveSXSSFCellComment
()
{
IWorkbook
wb
=
new
SXSSFWorkbook
();
try
{
ISheet
sheet
=
wb
.
CreateSheet
();
IRow
row
=
sheet
.
CreateRow
(
1
);
ICell
cell
=
row
.
CreateCell
(
0
);
cell
.
SetCellValue
(
"test"
);
IDrawing
drawing
=
sheet
.
CreateDrawingPatriarch
();
ICreationHelper
factory
=
wb
.
GetCreationHelper
();
// When the comment box is visible, have it show in a 1x3 space
IClientAnchor
anchor
=
factory
.
CreateClientAnchor
();
anchor
.
Col1
=
cell
.
ColumnIndex
;
anchor
.
Col2
=
cell
.
ColumnIndex
+
1
;
anchor
.
Row1
=
row
.
RowNum
;
anchor
.
Row2
=
row
.
RowNum
+
3
;
// Create the comment and set the text+author
IComment
comment
=
drawing
.
CreateCellComment
(
anchor
);
IRichTextString
str
=
factory
.
CreateRichTextString
(
"Hello, World!"
);
comment
.
String
=
str
;
comment
.
Author
=
"Apache POI"
;
cell
.
CellComment
=
comment
;
var
exCellComment
=
sheet
.
GetCellComment
(
new
CellAddress
(
1
,
0
));
Assert
.
IsNotNull
(
exCellComment
);
Assert
.
IsTrue
(
exCellComment
.
String
.
String
.
Equals
(
"Hello, World!"
));
Assert
.
IsTrue
(
exCellComment
.
Author
.
Equals
(
"Apache POI"
));
cell
.
RemoveCellComment
();
exCellComment
=
sheet
.
GetCellComment
(
new
CellAddress
(
1
,
0
));
Assert
.
IsNull
(
exCellComment
);
IComment
newComment
=
drawing
.
CreateCellComment
(
anchor
);
newComment
.
String
=
str
;
newComment
.
Author
=
"Apache POI"
;
cell
.
CellComment
=
newComment
;
exCellComment
=
sheet
.
GetCellComment
(
new
CellAddress
(
1
,
0
));
Assert
.
NotNull
(
exCellComment
);
Assert
.
IsTrue
(
exCellComment
.
String
.
String
.
Equals
(
"Hello, World!"
));
Assert
.
IsTrue
(
exCellComment
.
Author
.
Equals
(
"Apache POI"
));
}
finally
{
wb
.
Close
();
}
}
}
}
}
}
testcases/test-data/spreadsheet/738.xlsx
0 → 100644
浏览文件 @
0c08215d
文件已添加
testcases/test-data/spreadsheet/ATM.xls
0 → 100644
浏览文件 @
0c08215d
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录