Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Created Unassigned: Diagonal borders not loaded from template [15247]

$
0
0
When creating a new excel sheet from a template that has diagonal borders, the diagonal borders are removed.

The newly created styles.xml is missing the attributes diagonalUp="1" diagonalDown="1"

Below is the possible fix I am currently using

```
internal ExcelBorderXml(XmlNamespaceManager nsm, XmlNode topNode) :
base(nsm, topNode: topNode)
{
_left = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(leftPath, nsm));
_right = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(rightPath, nsm));
_top = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(topPath, nsm));
_bottom = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(bottomPath, nsm));
_diagonal = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(diagonalPath, nsm));

/* get diagonal attributes */
var attr = topNode.Attributes["diagonalUp"];
if (attr != null)
_diagonalUp = attr.Value == "1";
attr = topNode.Attributes["diagonalDown"];
if (attr != null)
_diagonalDown = attr.Value == "1";

}
```

and I have attached the test template and test code below

```
class SampleBorderDiagonal
{
/// <summary>
/// Sample 5 - open Sample 1 and add 2 new rows and a Piechart
/// </summary>
public static string RunSampleDiagonal(DirectoryInfo outputDir)
{
FileInfo templateFile = new FileInfo(outputDir.FullName + @"\diagonal.xlsx");
FileInfo newFile = new FileInfo(outputDir.FullName + @"\sampleDiagonal.xlsx");
if (newFile.Exists)
{
newFile.Delete(); // ensures we create a new workbook
newFile = new FileInfo(outputDir.FullName + @"\sampleDiagonal.xlsx");
}
using (ExcelPackage package = new ExcelPackage(newFile, templateFile))
{
//Open worksheet 1
ExcelWorksheet worksheet = package.Workbook.Worksheets[1];

Debug.WriteLine(worksheet.Cells["A1"].Style.Border.DiagonalUp);
Debug.WriteLine(worksheet.Cells["A1"].Style.Border.DiagonalDown);


//worksheet.Cells["A1"].Style.Border.DiagonalUp = true;
//worksheet.Cells["A1"].Style.Border.DiagonalDown = true;

// save our new workbook and we are done!
package.Save();
}

return newFile.FullName;
}
}
```


Viewing all articles
Browse latest Browse all 2262

Trending Articles



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