Using the file for MapPoint

Topics: Developer Forum
Oct 1, 2009 at 10:26 PM

I create a file with ExcelPackage and try to use it to import data to mappoint.

If I open the file with excel 2007 and then save with it, I can import it to MapPoint with no problems.

If I try to import directly, it fails with unknown error.

What is the save difference?

string FileName = MyPath + item.TERRITORY_NAME.Replace(", ", "_") + ".xlsx";
if (System.IO.File.Exists(FileName)) System.IO.File.Delete(FileName);
FileInfo newFile = new FileInfo(FileName);
using (ExcelPackage xlPackage = new ExcelPackage(newFile))
    ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets.Add("Custom Territories");
    worksheet.Cell(1, 1).Value = "ZIP Code"; worksheet.Cell(1, 2).Value = "Country/Region"; worksheet.Cell(1, 3).Value = "Territory";
    int xRowNum = 1;
    foreach (var Ter in TerGeo)
        worksheet.Cell(xRowNum, 1).Value = Ter.ZIPCODE;
        worksheet.Cell(xRowNum, 2).Value = "United States";
        worksheet.Cell(xRowNum, 3).Value = Ter.tblTO_DIM_TER.TERRITORY_NAME;
    xlPackage.Workbook.Properties.Title = item.TERRITORY_NAME;
    xlPackage.Workbook.Properties.Author = "Ofer Gal";
    xlPackage.Workbook.Properties.SetCustomPropertyValue("Number of Zips", NumZips.ToString() );

Maybe I need to close the file some how?