-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrefixedNamespaceTests.cs
More file actions
51 lines (44 loc) · 1.53 KB
/
PrefixedNamespaceTests.cs
File metadata and controls
51 lines (44 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Verifies that xlsx files created by the OpenXml SDK (which uses prefixed
// default namespaces like <x:worksheet xmlns:x="...">) are handled correctly.
[TestFixture]
public class PrefixedNamespaceTests
{
[Test]
public async Task OpenXmlSdkSpreadsheet()
{
using var document = CreateSpreadsheet();
await Verify(document);
}
static SpreadsheetDocument CreateSpreadsheet()
{
var stream = new MemoryStream();
var document = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook);
var workbookPart = document.AddWorkbookPart();
workbookPart.Workbook = new(new Sheets());
var worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new(new SheetData());
var sheets = workbookPart.Workbook.GetFirstChild<Sheets>()!;
sheets.Append(new Sheet
{
Id = workbookPart.GetIdOfPart(worksheetPart),
SheetId = 1,
Name = "Sheet1"
});
var sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>()!;
var row = new Row { RowIndex = 1 };
row.Append(new Cell
{
CellReference = "A1",
DataType = CellValues.InlineString,
InlineString = new(new Text("Hello"))
});
row.Append(new Cell
{
CellReference = "B1",
DataType = CellValues.InlineString,
InlineString = new(new Text("World"))
});
sheetData.Append(row);
return document;
}
}