We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

iF I run content 2 times then take that content few first round and add it also in round 2

It’s like that I have two names “JP, CLO” and when it runs CLO it also takes the content from JP and adds in my excel sheet. It should basically only take it from CLO and no one else.

var customerNameValue = Config.GetConfiguration().GetSection("CustomerName").Value.Split(",");
        foreach (var customerName in customerNameValue)
            List<TimeLogModel> output = new List<TimeLogModel>();
            var getCustomerText = Extension.GetCustomerText(customerName);

            foreach (DataRow row in dataTable.Rows)
                TimeLogModel item = new TimeLogModel();
                item.Customer = row.ItemArray[15].ToString().RemoveSign().ReplaceBadWords().ReplaceEmptyString();
                item.Name = row.ItemArray[6].ToString();
                item.Type = row.ItemArray[10].ToString().Split("-")[0] + "-" + row.ItemArray[10].ToString().Split("-")[1];
                item.WorkType = row.ItemArray[10].ToString().Split("-").Last();
                item.Work = row.ItemArray[3].ToString().SplitFrom();
                item.WorkMaxChar = row.ItemArray[3].ToString().SplitFrom().SubStringLength();
                item.Count = decimal.Parse(row.ItemArray[7].ToString());
                item.Price = PricesServices.GetPrices(row.ItemArray[6].ToString());
                item.SinglePrice = PricesServices.GetPricesTask(row.ItemArray[6].ToString(), decimal.Parse(row.ItemArray[7].ToString()));
                item.Att = getCustomerText.Item1;
                item.PSP = getCustomerText.Item2;


            var itemName = output.Where(r => r.Customer == customerName).GroupBy(r => r.Customer).Select(r => new TimeLogModel { Customer = r.Last().Customer });
            foreach (var item in itemName)
                var newFileName = FileServices.NewFileName(customerName);
                var getOutPutData = output
                    .Where(r => r.Customer == item.Customer)
                    .GroupBy(r => new
                    .Select(t => new TimeLogModel
                        Customer = t.Last().Customer,//Eller bruge customersName
                        Att = getCustomerText.Item1, //Att
                        PSP = getCustomerText.Item2, //PSP
                        Name = t.Last().Name, //CLO eller JP
                        Type = t.Last().Type, //Hvilken type
                        WorkType = t.Last().WorkType,//Seniorkonsulent, Chefkonsulent eller Konsulent.
                        Work = t.Last().Work,//Beskrivelse af opgaven
                        WorkMaxChar = t.Last().WorkMaxChar,//beskrivelse af opgaver (max 50)
                        Count = t.Sum(ta => ta.Count),//Timer
                        SinglePrice = PricesServices.GetPrices(t.Last().Name), //Single pris
                        Price = PricesServices.GetPricesTask(t.Last().Name, t.Sum(ta => ta.Count)), // Timer * Single Pris
                    .OrderByDescending(r => r.Work)

                bool checkValue = false;
                foreach (var itemCheck in getOutPutData)
                    if(itemCheck.Customer == customerName)
                        checkValue = true;

                if (checkValue)
                    var stringArray = new string[] { "Customer", "Att", "PSP", "Name", "Type", "WorkType", "Work", "WorkMaxChar", "Count", "SinglePrice", "Price" };
                    newWorkbook.Worksheets[0].Cells.ImportCustomObjects(getOutPutData, stringArray, true, 0, 0, getOutPutData.Count, true, "dd/mm/yyyy", false);
                    //Display value top
                    newWorkbook.Worksheets[0].Cells["H1"].PutValue("Opgave max 50 characters");
                    newWorkbook.Worksheets[0].Cells["J1"].PutValue("Styk pris");
                    newWorkbook.Save(filePath + newFileName);


We are not entirely certain about your issue. Could you please elaborate it more and share complete details. Moreover, we cannot evaluate your sample code as some objects, variables and data cannot be sorted out. We appreciate if you could create a standalone sample console application (sample code without compile time errors), zip the project and post us with resource files (if any) to reproduce the issue. You can exclude Aspose.Cells.Dll to minimze the size of the application prior attaching.