You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.
classPivotTest{privatestaticstringPIVOT_WS_NAME="Pivot";privatestaticstringDATA_WS_NAME="Data";internalvoidRunTest(){using(ExcelPackagexlp=new ExcelPackage()){
PrepareDoc(xlp);
GenPivot(xlp);FileStreamfs= File.Create("pivot.xlsx");
xlp.SaveAs(fs);
fs.Close();}}privatevoidPrepareDoc(ExcelPackagexlp){//generate date/value pairs for October 2017varseries= Enumerable.Range(0,31);vardata=fromxinseriesselectnew{ d =new DateTime(2017,10,x+1), x = x };//put data in tableExcelWorksheetws= xlp.Workbook.Worksheets.Add(DATA_WS_NAME);intcol=1;
ws.Cells[1,col++].Value ="Date";
ws.Cells[1, col].Value ="Value";introw=2;foreach(var line in data){col=1;
ws.Cells[row,col++].Value = line.d;
ws.Cells[row,col-1].Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
ws.Cells[row, col].Value = line.x;row++;}}privatevoidGenPivot(ExcelPackagexlp){ExcelWorksheetws= xlp.Workbook.Worksheets.Add(PIVOT_WS_NAME);ExcelWorksheetsrcws= xlp.Workbook.Worksheets[DATA_WS_NAME];ExcelPivotTablepiv= ws.PivotTables.Add(ws.Cells[1,1], srcws.Cells[1,1,32,2],"Pivot1");
piv.DataFields.Add(piv.Fields["Value"]);ExcelPivotTableFielddt= piv.RowFields.Add(piv.Fields["Date"]);
dt.AddDateGrouping(eDateGroupBy.Days | eDateGroupBy.Months);}}
When I open the pivot.xlsx file, I see the following (note that my system is setup with the Greek locale):
I un-zipped the xlsx file and the files seem all right; however, if I save the file from Excel without making any changes, the pivotTable1.xml file has the items in the pivotField in the wrong order. From that, I'm guessing that Excel messes-up the data when it reads the file.
The text was updated successfully, but these errors were encountered:
I have the following test code:
When I open the
pivot.xlsx
file, I see the following (note that my system is setup with the Greek locale):I un-zipped the xlsx file and the files seem all right; however, if I save the file from Excel without making any changes, the
pivotTable1.xml
file has theitem
s in thepivotField
in the wrong order. From that, I'm guessing that Excel messes-up the data when it reads the file.The text was updated successfully, but these errors were encountered: