Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color is not applying #207

Open
vel-kathir opened this issue Feb 14, 2024 · 0 comments
Open

Color is not applying #207

vel-kathir opened this issue Feb 14, 2024 · 0 comments

Comments

@vel-kathir
Copy link

vel-kathir commented Feb 14, 2024

Portfolio Data Saved and Processing and Checking of Portfolio Data && Review of Reconciliation and Reports and 2nd level review of Reconciliation & Reports Submitted and Release the Report to the Client start with (minus) means color red else green I need

const exportDelayWithSNo = response?.data?.employeeData?.map(
(item, index) => ({
"S.No": index + 1,
"Family Name": item.familyName,
"Portfolio Data Saved": convertDecimalDaysToTime(
item.task1balanceSla
),
"Processed by ": item.task1employeeName || "N/A",
"Processing and Checking of Portfolio Data":
convertDecimalDaysToTime(item.task2balanceSla),
"Processed by ": item.task2employeeName || "N/A",
"Reconciliation of Data and Reports": convertDecimalDaysToTime(
item.task3balanceSla
),
"Processed by ": item.task3employeeName || "N/A",
"Review of Reconciliation and Reports":
convertDecimalDaysToTime(item.task4balanceSla),
"Processed by ": item.task4employeeName || "N/A",
"2nd level review of Reconciliation & Reports Submitted":
convertDecimalDaysToTime(item.task5balanceSla),
"Processed by ": item.task5employeeName || "N/A",

            "Release the Report to the Client": convertDecimalDaysToTime(
              item.task6balanceSla
            ),
            "Processed by": item.task6employeeName || "N/A",
          })
        );
        // Include headers in the data array
        const headers = Object.keys(exportDelayWithSNo[0]);
        const dataWithHeaders = [headers]; // Assuming the first item contains column headers
        exportDelayWithSNo.forEach((row) => {
          const rowData = headers.map((header) => row[header]);
          dataWithHeaders.push(rowData);
        });

        const ws = XLSX.utils.aoa_to_sheet(dataWithHeaders);

        // Calculate column widths based on content length including headers
        const columnWidths = dataWithHeaders.reduce((acc, row) => {
          row.forEach((cell, index) => {
            const width = Math.max(acc[index] || 0, String(cell).length);
            acc[index] = width;
          });
          return acc;
        }, []);

        // Convert character length to Excel column width units
        const excelColumnWidths = columnWidths.map((width) => {
          return { wch: width };
        });

        ws["!cols"] = excelColumnWidths;

        const wb = XLSX.utils.book_new();
        XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
        const filename = `Customer_Analytics_Progress_${formattedDate}.xlsx`;
        XLSX.writeFile(wb, filename);
        
        
        const convertDecimalDaysToTime = (decimalDays) => {
const totalDays = Math.floor(Math.abs(decimalDays));
const remainingHours = Math.round((Math.abs(decimalDays) % 1) * 24);
const daysText =
  decimalDays < 0
    ? `-${totalDays} ${
        totalDays === 0 || totalDays === 1 ? "Day" : "Days"
      } `
    : `${totalDays} ${
        totalDays === 0 || totalDays === 1 ? "Day" : "Days"
      } `;
const hoursText = `${remainingHours} ${
  remainingHours === 0 || remainingHours === 1 ? "Hour" : "Hours"
} `;

return `${daysText}${hoursText}` === "-0 Day 0 Hour "
  ? "0 Day 0 Hour"
  : `${daysText}${hoursText}`;

};

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant