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

Max content height is not working #364

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

Max content height is not working #364

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

Comments

@vel-kathir
Copy link

const handleExport = (data) => {
const title = [
[
"SL.No",
"Employee Name",
"Portfolio data saved",
"Processed by",
"Processing and Checking of portfolio data",
"Processed by",
"Reconciliation of data and reports",
"Processed by",
"Review of reconciliation and reports",
"Processed by",
"2nd level review of reconciliation and reports submitted by SRM",
"Processed by",
"Release the report to the client",
"Processed by",
],
];

const getCellStyle = (val) => {
  const stringValue = String(val);
  const numericValue = parseFloat(stringValue);
  console.log(numericValue, "luslhfhksgfkgjkgjhjkl");
  return isNaN(numericValue)
    ? "000000"
    : numericValue === 0
    ? stringValue.startsWith("-")
      ? "E2A42C"
      : "00861D"
    : numericValue < 0
    ? "E22C2C"
    : "00861D";
};

const rows = data.flatMap((family, index) => {
  return [
    [
      index + 1,
      family.familyName,
      family.task1balanceSla === 0 || family.task1balanceSla === null
        ? ""
        : convertDecimalDaysToTime(family.task1balanceSla),
      family.task1employeeName || "N/A",
      family.task2balanceSla === 0 || family.task2balanceSla === null
        ? ""
        : convertDecimalDaysToTime(family.task2balanceSla),
      family.task2employeeName || "N/A",
      family.task3balanceSla === 0 || family.task3balanceSla === null
        ? ""
        : convertDecimalDaysToTime(family.task3balanceSla),
      family.task3employeeName || "N/A",
      family.task4balanceSla === 0 || family.task4balanceSla === null
        ? ""
        : convertDecimalDaysToTime(family.task4balanceSla),
      family.task4employeeName || "N/A",
      family.task5balanceSla === 0 || family.task5balanceSla === null
        ? ""
        : convertDecimalDaysToTime(family.task5balanceSla),
      family.task5employeeName || "N/A",
      family.task6balanceSla === 0 || family.task6balanceSla === null
        ? ""
        : convertDecimalDaysToTime(family.task6balanceSla),
      family.task6employeeName || "N/A",
    ],
  ];
});

const finalData = [...title, ...rows];

return XlsxPopulate.fromBlankAsync()
  .then((workbook) => {
    finalData.forEach((row, rowIndex) => {
      row.forEach((cellValue, colIndex) => {
        const cell = workbook.sheet(0).cell(rowIndex + 1, colIndex + 1);
        cell.value(cellValue);
        console.log(cellValue, parseFloat(cellValue));
        if (
          colIndex === 2 ||
          colIndex === 4 ||
          colIndex === 6 ||
          colIndex === 8 ||
          colIndex === 10 ||
          colIndex === 12
        ) {
          cell.style({
            fontColor: getCellStyle(cellValue),
          });
        }
        cell.style({
          horizontalAlignment: "center",
          verticalAlignment: "center",
          wrapText: true,
        });
      });
    });

    workbook.sheet(0).range("A1:N1").style({
      bold: true,
      horizontalAlignment: "center",
      verticalAlignment: "center",
      fontColor: "000000",
    });
    workbook.sheet(0).row(1).height(25);
    const columnWidths = [
      8, 20, 25, 30, 40, 30, 35, 30, 40, 30, 65, 30, 35, 30,
    ];
    columnWidths.forEach((width, index) => {
      workbook
        .sheet(0)
        .column(index + 1)
        .width(width);
    });

    return workbook.outputAsync();
  })
  .then((blob) => URL.createObjectURL(blob));

};

handleExport(response?.data?.employeeData).then((url) => {
const downloadAnchorNode = document.createElement("a");
downloadAnchorNode.setAttribute("href", url);
downloadAnchorNode.setAttribute(
"download",
Customer_Analytics_Progress_${formattedDate}.xlsx
);
downloadAnchorNode.click();
downloadAnchorNode.remove();
});

image

@vel-kathir vel-kathir changed the title Max height is not working Max content height is not working Feb 23, 2024
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