Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Commit

Permalink
Fixed issue #5,#25,#27
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.kallman@alecta.com committed Oct 11, 2017
1 parent 552a146 commit 945a476
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 27 deletions.
12 changes: 12 additions & 0 deletions EPPlus/EPPlus.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyVersion>4.5.0.0</AssemblyVersion>
<FileVersion>4.5.0.0</FileVersion>
<Version>4.5.0</Version>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageLicenseUrl>https://www.gnu.org/licenses/lgpl-3.0.en.html</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/JanKallman/EPPlus</PackageProjectUrl>
<Authors>Jan Källman</Authors>
<Company />
<Product>EPPlus</Product>
<Description>Create advanced Excel spreadsheets using DotNet</Description>
<AssemblyName>EPPlus</AssemblyName>
<RootNamespace>EPPlus</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
1 change: 1 addition & 0 deletions EPPlus/EPPlus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@
<ItemGroup>
<Compile Include="ConditionalFormatting\CF Implementation.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
7 changes: 5 additions & 2 deletions EPPlus/ExcelPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ internal class ImageInfo
/// Main Xml schema name
/// </summary>
internal const string schemaMain = @"http://schemas.openxmlformats.org/spreadsheetml/2006/main";

/// <summary>
/// Relationship schema name
/// </summary>
Expand All @@ -214,7 +215,8 @@ internal class ImageInfo
internal const string schemaDcmiType = @"http://purl.org/dc/dcmitype/";
internal const string schemaXsi = @"http://www.w3.org/2001/XMLSchema-instance";
internal const string schemaVt = @"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";


internal const string schemaMainX14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
//Pivottables
internal const string schemaPivotTable = @"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
internal const string schemaPivotCacheDefinition = @"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
Expand Down Expand Up @@ -685,7 +687,7 @@ private XmlNamespaceManager CreateDefaultNSM()
NameTable nt = new NameTable();
var ns = new XmlNamespaceManager(nt);
ns.AddNamespace(string.Empty, ExcelPackage.schemaMain);
ns.AddNamespace("d", ExcelPackage.schemaMain);
ns.AddNamespace("d", ExcelPackage.schemaMain);
ns.AddNamespace("r", ExcelPackage.schemaRelationships);
ns.AddNamespace("c", ExcelPackage.schemaChart);
ns.AddNamespace("vt", schemaVt);
Expand All @@ -700,6 +702,7 @@ private XmlNamespaceManager CreateDefaultNSM()
ns.AddNamespace("dcterms", schemaDcTerms);
ns.AddNamespace("dcmitype", schemaDcmiType);
ns.AddNamespace("xsi", schemaXsi);
ns.AddNamespace("x14", schemaMainX14);
return ns;
}

Expand Down
1 change: 1 addition & 0 deletions EPPlus/ExcelStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ private void SetStyleAddress(StyleBase sender, Style.StyleChangeEventArgs e, Exc
var newColumn = ws.Column(column._columnMax + 1);
newColumn.ColumnMax = address.End.Column;
AddNewStyleColumn(sender, e, ws, styleCashe, newColumn, newColumn.StyleID);
column = newColumn;
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions EPPlus/ExcelWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* ******************************************************************************
* Jan Källman Initial Release 2011-01-01
* Jan Källman License changed GPL-->LGPL 2011-12-27
* Richard Tallent Fix escaping of quotes 2012-10-31
* Richard Tallent Fix escaping of quotes 2012-10-31
*******************************************************************************/
using System;
using System.Xml;
Expand Down Expand Up @@ -107,7 +107,7 @@ internal class SharedStringItem
_names = new ExcelNamedRangeCollection(this);
_namespaceManager = namespaceManager;
TopNode = WorkbookXml.DocumentElement;
SchemaNodeOrder = new string[] { "fileVersion", "fileSharing", "workbookPr", "workbookProtection", "bookViews", "sheets", "functionGroups", "functionPrototypes", "externalReferences", "definedNames", "calcPr", "oleSize", "customWorkbookViews", "pivotCaches", "smartTagPr", "smartTagTypes", "webPublishing", "fileRecoveryPr", };
SchemaNodeOrder = new string[] { "fileVersion", "fileSharing", "workbookPr", "workbookProtection", "bookViews", "sheets", "functionGroups", "functionPrototypes", "externalReferences", "definedNames", "calcPr", "oleSize", "customWorkbookViews", "pivotCaches", "smartTagPr", "smartTagTypes", "webPublishing", "fileRecoveryPr", "webPublishObjects", "extLst" };
FullCalcOnLoad = true; //Full calculation on load by default, for both new workbooks and templates.
GetSharedStrings();
}
Expand Down
4 changes: 2 additions & 2 deletions EPPlus/ExcelWorksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4111,7 +4111,7 @@ public ExcelProtectedRangeCollection ProtectedRanges
}
}

#region Drawing
#region Drawing
ExcelDrawings _drawings = null;
/// <summary>
/// Collection of drawing-objects like shapes, images and charts
Expand All @@ -4127,7 +4127,7 @@ public ExcelDrawings Drawings
return _drawings;
}
}
#endregion
#endregion
ExcelTableCollection _tables = null;
/// <summary>
/// Tables defined in the worksheet.
Expand Down
25 changes: 14 additions & 11 deletions EPPlus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//[assembly: AssemblyTitle("EPPlus")]
//[assembly: AssemblyDescription("Allows Excel files(xlsx;xlsm) to be created on the server. See epplus.codeplex.com")]
//[assembly: AssemblyConfiguration("")]
//[assembly: AssemblyCompany("EPPlus")]
//[assembly: AssemblyProduct("EPPlus")]
//[assembly: AssemblyCopyright("Copyright 2009- ©Jan Källman. Parts of the Interface comes from the ExcelPackage-project")]
//[assembly: AssemblyTrademark("The GNU Lesser General Public License (LGPL)")]
//[assembly: AssemblyCulture("")]
//[assembly: ComVisible(false)]
[assembly: InternalsVisibleTo("EPPlusTest, PublicKey=00240000048000009400000006020000002400005253413100040000010001001dd11308ec93a6ebcec727e183a8972dc6f95c23ecc34aa04f40cbfc9c17b08b4a0ea5c00dcd203bace44d15a30ce8796e38176ae88e960ceff9cc439ab938738ba0e603e3d155fc298799b391c004fc0eb4393dd254ce25db341eb43303e4c488c9500e126f1288594f0710ec7d642e9c72e76dd860649f1c48249c00e31fba")]

// The following GUID is for the ID of the typelib if this project is exposed to COM
Expand All @@ -60,6 +51,18 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
#if (!Core)
[assembly: AssemblyTitle("EPPlus")]
[assembly: AssemblyDescription("Allows Excel files(xlsx;xlsm) to be created on the server. See epplus.codeplex.com")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EPPlus")]
[assembly: AssemblyProduct("EPPlus")]
[assembly: AssemblyCopyright("Copyright 2009- ©Jan Källman. Parts of the Interface comes from the ExcelPackage-project")]
[assembly: AssemblyTrademark("The GNU Lesser General Public License (LGPL)")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

[assembly: AssemblyVersion("4.5.0.0")]
[assembly: AssemblyFileVersion("4.5.0.0")]
#endif
[assembly: AllowPartiallyTrustedCallers]
1 change: 0 additions & 1 deletion EPPlus/Style/ExcelColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public sealed class ExcelColor : StyleBase
StyleBase _parent;
internal ExcelColor(ExcelStyles styles, OfficeOpenXml.XmlHelper.ChangedEventHandler ChangedEvent, int worksheetID, string address, eStyleClass cls, StyleBase parent) :
base(styles, ChangedEvent, worksheetID, address)

{
_parent = parent;
_cls = cls;
Expand Down
2 changes: 1 addition & 1 deletion EPPlus/VBA/ExcelVBAProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ private byte[] CreateProjectwmStream()
bw.Write((ushort)0); //Null
}
bw.Write((ushort)0); //Null
return VBACompression.CompressPart(((MemoryStream)bw.BaseStream).ToArray());
return ((MemoryStream)bw.BaseStream).ToArray();
}
private byte[] CreateProjectStream()
{
Expand Down
63 changes: 61 additions & 2 deletions EPPlusTest/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using OfficeOpenXml.Table.PivotTable;
using OfficeOpenXml.Drawing.Chart;
using System.Text;
using System.Dynamic;

namespace EPPlusTest
{
Expand Down Expand Up @@ -1581,7 +1582,65 @@ public void Issue_15641()
sheet.Cells[1, 1].Copy(sheet.Cells[3, 1]); //A3

Assert.AreEqual(true, sheet.Cells[3, 1].IsArrayFormula);

}
[TestMethod]
public void Issue_5()
{
var excelFile = new FileInfo(@"c:\temp\bug\test.xlsm");
using (var package = new ExcelPackage(excelFile))
{
var ws = package.Workbook.Worksheets.Add("NewWorksheet");
ws.CodeModule.Code = "Private Sub Worksheet_SelectionChange(ByVal Target As Range)\r\n\r\nEnd Sub";
package.SaveAs(new FileInfo(@"c:\temp\bug\vbafailSaved.xlsm"));
}
}
[TestMethod]
public void Issue_8()
{
dynamic c = 1;

var l = new List<dynamic>();
l.Add(1);
l.Add("s");
using (var package = new ExcelPackage())
{
var ws = package.Workbook.Worksheets.Add("Dynamic Test");
ws.Cells["a1"].LoadFromCollection(l);
package.SaveAs(new FileInfo(@"c:\temp\dynamic.xlsx"));
}


}
[TestMethod]
public void Issuer27()
{
FileInfo file = new FileInfo(@"C:\Temp\Test.xlsx");
var pck = new ExcelPackage(file);
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Worksheet");
if (ws != null)
{
ws.Cells["A1"].Value = "Cell value 1";
ws.Cells["B1"].Value = "Cell value 2";
ws.Cells["C1"].Value = "Cell value 3";
ws.Cells["D1"].Value = "Cell value 4";
ws.Cells["E1"].Value = "Cell value 5";
}
//ws.Cells.Style.VerticalAlignment = ExcelVerticalAlignment::Top; // Columns 4 and greater hidden
ws.Cells.AutoFitColumns(0);
ws.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Top; // 4.1.1.0 - exception, 4.0.4.0 - columns 4 and 5 hidden
ws.Column(4).Hidden = true;
ws.Column(5).Hidden = true; // span exception
pck.Save();
}
[TestMethod]
public void Issuer26()
{
FileInfo file = new FileInfo(@"C:\Temp\repeatrowcol.xlsx");
var pck = new ExcelPackage(file);
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Worksheet");
ws.PrinterSettings.RepeatRows = new ExcelAddress("1:1");
ws.PrinterSettings.RepeatColumns = new ExcelAddress("A:A");
pck.Save();
}
}
}
}
22 changes: 16 additions & 6 deletions EPPlusTest/VBA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void ReadVBA()
}

List<X509Certificate2> ret = new List<X509Certificate2>();
X509Store store = new X509Store(StoreName.My,StoreLocation.CurrentUser);
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
package.Workbook.VbaProject.Signature.Certificate = store.Certificates[19];
//package.Workbook.VbaProject.Protection.SetPassword("");
Expand Down Expand Up @@ -115,7 +115,7 @@ public void WriteLongVBAModule()

package.SaveAs(new FileInfo(@"c:\temp\vbaLong.xlsm"));
}
[Ignore]
[Ignore]
[TestMethod]
public void VbaError()
{
Expand Down Expand Up @@ -173,7 +173,7 @@ public void CreateUnicodeWsName()
sb.AppendLine("Sub GetData()");
sb.AppendLine("MsgBox (\"Hello,World\")");
sb.AppendLine("End Sub");

ExcelWorksheet worksheet2 = package.Workbook.Worksheets.Add("Sheet1");
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Private Sub Worksheet_Change(ByVal Target As Range)");
Expand All @@ -189,13 +189,13 @@ public void CreateUnicodeWsName()
[TestMethod]
public void VbaBug()
{
using ( var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\outfile.xlsm")))
using (var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\outfile.xlsm")))
{
Console.WriteLine(package.Workbook.CodeModule.Code.Length);
package.Workbook.Worksheets[1].CodeModule.Code = "Private Sub Worksheet_SelectionChange(ByVal Target As Range)\r\n\r\nEnd Sub";
package.Workbook.Worksheets.Add("TestCopy",package.Workbook.Worksheets[1]);
package.Workbook.Worksheets.Add("TestCopy", package.Workbook.Worksheets[1]);
package.SaveAs(new FileInfo(@"c:\temp\bug\outfile2.xlsm"));
}
}
}
[TestMethod]
public void DecompressionChunkGreaterThan4k()
Expand All @@ -220,5 +220,15 @@ public void DecompressionChunkGreaterThan4k()
}
}
}
[TestMethod]
public void ReadNewVBA()
{
using (var package = new ExcelPackage(new FileInfo(@"c:\temp\bug\makro.xlsm")))
{
Console.WriteLine(package.Workbook.VbaProject.Modules[0].Name);

package.SaveAs(new FileInfo(@"c:\temp\bug\makroepp.xlsm"));
}
}
}
}

1 comment on commit 945a476

@davidgeewhiz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to commit change to CellStore class, to make it public?

public class CellStore : IDisposable// : IEnumerable, IEnumerator

Otherwise C++ users won't be able to compile with 4.1.1.0 release.

Please sign in to comment.