Skip to content

Instantly share code, notes, and snippets.

View rapsacnz's full-sized avatar
🏠
Working from home

Caspar Harmer rapsacnz

🏠
Working from home
View GitHub Profile
@rapsacnz
rapsacnz / gist:72467da615b9ae46530d
Created November 13, 2014 22:37
JavaScript Report Postprocesser
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Stack Report</title>
<script language="JavaScript" type="text/javascript">/*! jQuery v1.9.0 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license */
(function (e, t) {
"use strict";
function n(e) {
var t = e.length, n = st.type(e);
public ExcelExportController() {
xmlheader ='<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>';
endfile = '</Workbook>';
opportunities = [SELECT Id, Name, StageName, Amount FROM Opportunity LIMIT 10];
oppSize = opportunities.size();
}
<apex:page id="pg" standardStylesheets="false" controller="ExcelExportController"
contenttype="application/vnd.ms-excel#TestExport_{!TODAY()}.xls">
<apex:outputText value="{!xmlheader}" escape="false"/>
<!-- your excel output goes here -->
<apex:outputText value="{!endfile}" escape="false"/>
</apex:page>
<Names>
<NamedRange ss:Name="Amount_Column" ss:RefersTo="=Opportunities!R2C3:R{!oppSize + 1}C3"/>
<NamedRange ss:Name="Name_Column" ss:RefersTo="=Opportunities!R2C1:R{!oppSize + 1}C1"/>
<NamedRange ss:Name="Percentage_of_Total_Column" ss:RefersTo="=Opportunities!R2C4:R{!oppSize + 1}C4"/>
<NamedRange ss:Name="Stage_Column" ss:RefersTo="=Opportunities!R2C2:R{!oppSize + 1}C2"/>
<NamedRange ss:Name="Total_Amount_Cell" ss:RefersTo="=Opportunities!R{!oppSize + 2}C3"/>
</Names>
<apex:repeat value="{!opportunities}" var="opp">
<Row>
<Cell ><Data ss:Type="String">{!opp.Name}</Data>
<NamedCell ss:Name="Name_Column"/></Cell>
<Cell ><Data ss:Type="String">{!opp.StageName}</Data>
<NamedCell ss:Name="Stage_Column"/></Cell>
<Cell ><Data ss:Type="Number">{!opp.Amount}</Data>
<NamedCell ss:Name="Amount_Column"/></Cell>
<Cell ss:StyleID="s75" ss:Formula="=IFERROR(RC[-1]/Total_Amount_Cell,0)"><Data
ss:Type="Number"></Data>
<Row ss:Height="19">
<Cell ss:StyleID="s67"/>
<Cell ss:StyleID="s67"><Data ss:Type="String">Totals</Data></Cell>
<Cell ss:StyleID="s67" ss:Formula="=SUM(Amount_Column)"><Data ss:Type="Number"></Data></Cell>
<Cell ss:StyleID="s70" ss:Formula="=SUM(Percentage_of_Total_Column)"><Data
ss:Type="Number"></Data></Cell>
</Row>
<apex:page applyBodyTag="false" controller="YourController" extensions="LookupController" docType="html-5.0" showHeader="true" sidebar="false" standardStylesheets="false">
<html xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<head>
<apex:includeScript value="/lightning/lightning.out.js"/>
<apex:stylesheet value="{!URLFOR($Resource.SLDS0110, 'assets/styles/salesforce-lightning-design-system-vf.css')}"/>
</head>
<body >
<div class="slds">
<div class="slds-form-element slds-m-top--xx-small">
<div class="slds-m-right--x-small" id="account_lookup"></div>
@rapsacnz
rapsacnz / Utilities.cls
Created June 20, 2017 22:01
Apex Utilities
/**
* Created by caspar on 20/05/16.
*/
public without sharing class Utilities {
public static Map<String, List<String>> fieldsForType = new Map<String, List<String>>();
/**
* Retrieves a list of sObjects
@rapsacnz
rapsacnz / ScriptLoadHelper.js
Created September 10, 2018 18:39
Load up scripts using Promises in Lightning
getResouce: function(component, scriptName, resourceName) {
return new Promise($A.getCallback(function(resolve, reject) {
if (component.get("v.scriptsLoaded") == true) {
resolve(window[scriptName]);
}
else {
// Create script element and set attributes
var script = document.createElement('script');
@rapsacnz
rapsacnz / Books.txt
Created February 27, 2019 02:35
Books Read By Kris Gray That I Haven't Read
A Game of Thrones
The Moon is a Harsh Mistress
Jurassic Park
Chasm City
A Clash of Kings
A Storm of Swords
A Feast of Crows
A Dance with Dragons
Heir to the Empire
Lord of the Silver Bow