Skip to content

Instantly share code, notes, and snippets.

@spenserhale
Created February 11, 2026 02:22
Show Gist options
  • Select an option

  • Save spenserhale/233afa7ecc4d453ed7cfb5974f421edd to your computer and use it in GitHub Desktop.

Select an option

Save spenserhale/233afa7ecc4d453ed7cfb5974f421edd to your computer and use it in GitHub Desktop.
Lattice Export Employees to CSV
javascript:(function(){const rows=Array.from(document.querySelectorAll('tbody tr')).filter(row=>row.querySelector('td'));if(rows.length===0){console.error("No employee rows found. Make sure you're on the directory page.");return;}const csvData=[];csvData.push('"Name","Title","Department","Manager","Start Date"');rows.forEach(row=>{const cells=Array.from(row.querySelectorAll('td'));const nameCell=cells[0];const nameSpan=nameCell.querySelector('span.chakra-text[title]');const titleSpan=nameCell.querySelectorAll('span.chakra-text')[1];const name=nameSpan?nameSpan.textContent.trim():'';const title=titleSpan?titleSpan.textContent.trim():'';const deptCell=cells[1];const department=deptCell?deptCell.textContent.trim():'';const managerCell=cells[2];const manager=managerCell?managerCell.textContent.trim():'';const startDateCell=cells[3];const startDate=startDateCell?startDateCell.textContent.trim():'';const escapeCsv=str=>`"${str.replace(/"/g,'""')}"`;csvData.push([escapeCsv(name),escapeCsv(title),escapeCsv(department),escapeCsv(manager),escapeCsv(startDate)].join(','));});const csvContent="data:text/csv;charset=utf-8,"+csvData.join("\n");const encodedUri=encodeURI(csvContent);const link=document.createElement("a");link.setAttribute("href",encodedUri);link.setAttribute("download","lattice_directory_export.csv");document.body.appendChild(link);link.click();document.body.removeChild(link);console.log(`✅ Successfully exported ${rows.length} employees to CSV`);console.log("Sample row:",csvData[1]);})();
(function() {
// Find all employee rows (exclude header rows)
const rows = Array.from(document.querySelectorAll('tbody tr'))
.filter(row => row.querySelector('td')); // Only rows with td cells
if (rows.length === 0) {
console.error("No employee rows found. Make sure you're on the directory page.");
return;
}
const csvData = [];
// CSV Header
csvData.push('"Name","Title","Department","Manager","Start Date"');
rows.forEach(row => {
const cells = Array.from(row.querySelectorAll('td'));
// Column 0: Name and Title (both in first <td>)
const nameCell = cells[0];
const nameSpan = nameCell.querySelector('span.chakra-text[title]');
const titleSpan = nameCell.querySelectorAll('span.chakra-text')[1]; // Second span is the title
const name = nameSpan ? nameSpan.textContent.trim() : '';
const title = titleSpan ? titleSpan.textContent.trim() : '';
// Column 1: Department
const deptCell = cells[1];
const department = deptCell ? deptCell.textContent.trim() : '';
// Column 2: Manager
const managerCell = cells[2];
const manager = managerCell ? managerCell.textContent.trim() : '';
// Column 3: Start Date
const startDateCell = cells[3];
const startDate = startDateCell ? startDateCell.textContent.trim() : '';
// Escape quotes and wrap in quotes for CSV
const escapeCsv = (str) => `"${str.replace(/"/g, '""')}"`;
csvData.push([
escapeCsv(name),
escapeCsv(title),
escapeCsv(department),
escapeCsv(manager),
escapeCsv(startDate)
].join(','));
});
// Download CSV
const csvContent = "data:text/csv;charset=utf-8," + csvData.join("\n");
const encodedUri = encodeURI(csvContent);
const link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "lattice_directory_export.csv");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
console.log(`✅ Successfully exported ${rows.length} employees to CSV`);
console.log("Sample row:", csvData[1]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment