问:
SQL - Finding sequence of events
I need some help identifying a sequence of events in SQL Server 08 R2.
This is the sample data:

```<code>    ID | SampleTime | SampleValue | CycleNum
    1  | 07:00:00   | 10          |
    2  | 07:02:00   | 10          |
    3  | 07:05:00   | 10          |
    4  | 07:12:00   | 20          |
    5  | 07:15:00   | 10          |
    6  | 07:22:00   | 10          |
    7  | 07:23:00   | 20          |
    8  | 07:30:00   | 20          |
    9  | 07:31:00   | 10          |
</code>```

I have used the following as a guide, link
, but it doesn't give the required output

The rules are:

A cycle starts at 10 and finishes at 20

There can be multiple 10s before a 20, and multiple 20s before the next 10

A cycle will always start at the first 10, and finish on the last 20 before the next 10.

Example Output

```<code>    ID | SampleTime | SampleValue | CycleNum
    1  | 07:00:00   | 10          |  1
    2  | 07:02:00   | 10          |  1
    3  | 07:05:00   | 10          |  1
    4  | 07:12:00   | 20          |  1
    5  | 07:15:00   | 10          |  2
    6  | 07:22:00   | 10          |  2
    7  | 07:23:00   | 20          |  2
    8  | 07:30:00   | 20          |  2
    9  | 07:31:00   | 10          |  3
</code>```

Test Table

```<code>CREATE TABLE myTable (ID INT IDENTITY, SampleTime DATETIME, SampleValue INT, CycleNum INT)
INSERT INTO myTable (SampleTime, SampleValue)
VALUES ('07:00:00',10),
       ('07:02:00',10),
       ('07:05:00',10),
       ('07:12:00',20),
       ('07:15:00',10),
       ('07:22:00',10),
       ('07:23:00',20),
       ('07:30:00',20),
       ('07:31:00',10)
</code>```

答:
Try this... this will give the mapping of ID and CYCLENUM</p>

```<code>WITH EVE_DATA AS (
  SELECT ID
    , SAMPLETIME
    , SAMPLEVALUE
    , CASE
        WHEN (SAMPLEVALUE - lag(SAMPLEVALUE, 1, 0) over (order by SAMPLETIME ASC)) = -10
        THEN 1
        ELSE 0
    END AS START_IND
  FROM
  MY_TABLE
)
SELECT T1.id
  , SUM(T2.START_IND) + 1 AS CycleNum
FROM EVE_DATA T1
  JOIN EVE_DATA T2
    ON T1.ID >= T2.ID
GROUP BY T1.ID
ORDER BY T1.ID;
</code>```

Title: SQL - Finding sequence of events

Body:
I need some help identifying a sequence of events in SQL Server 08 R2.
This is the sample data:

    ID | SampleTime | SampleValue | CycleNum
    1  | 07:00:00   | 10          |
    2  | 07:02:00   | 10          |
    3  | 07:05:00   | 10          |
    4  | 07:12:00   | 20          |
    5  | 07:15:00   | 10          |
    6  | 07:22:00   | 10          |
    7  | 07:23:00   | 20          |
    8  | 07:30:00   | 20          |
    9  | 07:31:00   | 10          |

I have used the following as a guide, link
, but it doesn't give the required output

The rules are:

A cycle starts at 10 and finishes at 20

There can be multiple 10s before a 20, and multiple 20s before the next 10

A cycle will always start at the first 10, and finish on the last 20 before the next 10.

Example Output

    ID | SampleTime | SampleValue | CycleNum
    1  | 07:00:00   | 10          |  1
    2  | 07:02:00   | 10          |  1
    3  | 07:05:00   | 10          |  1
    4  | 07:12:00   | 20          |  1
    5  | 07:15:00   | 10          |  2
    6  | 07:22:00   | 10          |  2
    7  | 07:23:00   | 20          |  2
    8  | 07:30:00   | 20          |  2
    9  | 07:31:00   | 10          |  3

Test Table

CREATE TABLE myTable (ID INT IDENTITY, SampleTime DATETIME, SampleValue INT, CycleNum INT)
INSERT INTO myTable (SampleTime, SampleValue)
VALUES ('07:00:00',10),
       ('07:02:00',10),
       ('07:05:00',10),
       ('07:12:00',20),
       ('07:15:00',10),
       ('07:22:00',10),
       ('07:23:00',20),
       ('07:30:00',20),
       ('07:31:00',10)

Body:
Try this... this will give the mapping of ID and CYCLENUM

WITH EVE_DATA AS (
  SELECT ID
    , SAMPLETIME
    , SAMPLEVALUE
    , CASE
        WHEN (SAMPLEVALUE - lag(SAMPLEVALUE, 1, 0) over (order by SAMPLETIME ASC)) = -10
        THEN 1
        ELSE 0
    END AS START_IND
  FROM
  MY_TABLE
)
SELECT T1.id
  , SUM(T2.START_IND) + 1 AS CycleNum
FROM EVE_DATA T1
  JOIN EVE_DATA T2
    ON T1.ID >= T2.ID
GROUP BY T1.ID
ORDER BY T1.ID;


来源: stackexchange

问:
Javascript Split Space Delimited String and Trim Extra Commas and Spaces
I need to split a keyword string and turn it into a comma delimited string. However, I need to get rid of extra spaces and any commas that the user has already input.

```<code>var keywordString = "ford    tempo, with,,, sunroof";
</code>```

Output to this string:

```<code>ford,tempo,with,sunroof,
</code>```

I need the trailing comma and no spaces in the final output.

Not sure if I should go Regex or a string splitting function.

Anyone do something like this already?

I need to use javascript (or JQ).

EDIT (working solution):

```<code>var keywordString = ", ,, ford,    tempo, with,,, sunroof,, ,";

//remove all commas; remove preceeding and trailing spaces; replace spaces with comma

str1 = keywordString.replace(/,/g , '').replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace(/[\s,]+/g, ',');

//add a comma at the end
str1 = str1 + ',';

console.log(str1);
</code>```

答:
In ES6:

```<code>var temp = str.split(",").map((item)=>item.trim());
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I need to split a keyword string and turn it into a comma delimited string. However, I need to get rid of extra spaces and any commas that the user has already input.

var keywordString = "ford    tempo, with,,, sunroof";

Output to this string:

ford,tempo,with,sunroof,

I need the trailing comma and no spaces in the final output.

Not sure if I should go Regex or a string splitting function.

Anyone do something like this already?

I need to use javascript (or JQ).

EDIT (working solution):

var keywordString = ", ,, ford,    tempo, with,,, sunroof,, ,";

//remove all commas; remove preceeding and trailing spaces; replace spaces with comma

str1 = keywordString.replace(/,/g , '').replace(/^\s\s*/, '').replace(/\s\s*$/, '').replace(/[\s,]+/g, ',');

//add a comma at the end
str1 = str1 + ',';

console.log(str1);

Body:
In ES6:

var temp = str.split(",").map((item)=>item.trim());


问:
How do I get rid of these errors in my code? NumberFormatException: for input string: ""
```<code>Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at HelloWorld.main(HelloWorld.java:169)
</code>```

These errors continue to pop up when I run my code against our sample input. We are given a document with polygons and have to use kruskal's algorithm and build a minimal spanning tree to find the shortest distance to each island without creating a cycle. If anyone can help or give advice on how to get rid of these errors that would be great! I dont understand how there can be a numberformatexception on a string ""....

```<code>import java.util.Scanner;
import java.util.ArrayList;
import java.io.File;
import java.io.IOException;

public class HelloWorld {
static class Point {
    int x = 0;
    int y = 0;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public String toString() {
        return "(x: " + x + " y: " + y + ")";
    }
}

static class Polygon {
    int numberOfVertices = 0;
    ArrayList<Point> points = new ArrayList<Point>();

    public Polygon(int numberOfVertices, ArrayList<Point> points) {
        this.numberOfVertices = numberOfVertices;
        this.points = points;
    }

    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < points.size(); i++) {
            Point point = this.points.get(i);
            stringBuilder.append(point);
        }

        return stringBuilder.toString();
    }
}

static class PQItem implements Comparable<PQItem> {
    int node1;
    int node2;
    double edge;

    public PQItem(int node1, int node2, double edge) {
        this.node1 = node1;
        this.node2 = node2;
        this.edge = edge;
    }

    public int compareTo(PQItem T) {
        if (edge - T.edge < 0)
            return 1;
        else if (edge - T.edge > 0)
            return -1;
        else
            return 0;
    }

}

public static void BuildMinimalSpanningTree(int numberOfIslands, ArrayList<Polygon> polygons) {
    PriorityQueue q = new PriorityQueue((numberOfIslands * numberOfIslands) / 2);
    PQItem Temp;
    int[] CheckPad = new int[numberOfIslands];
    int FootPrint = 0;
    int counter = 0;
    double length = 0;

    for (int i = 0; i < polygons.size(); i++)
        for (int j = 0; j < polygons.size(); j++) {
            Temp = new PQItem(i, j, ShortestDistance(polygons.get(i), polygons.get(j)));
        }

    for (int i = 0; i < polygons.size(); i++)
        CheckPad[i] = -1 - i;
    while (counter < polygons.size() - 1) {
        Temp = (PQItem) q.Remove();
        for (int i = 0; i < polygons.size(); i++)
            for (int j = 0; j < polygons.size(); j++)
                if (CheckPad[Temp.node1] != CheckPad[Temp.node2]) {
                    if (CheckPad[Temp.node1] < 0 && CheckPad[Temp.node2] < 0) {
                        CheckPad[Temp.node1] = FootPrint;
                        CheckPad[Temp.node2] = FootPrint;
                        FootPrint = FootPrint + 1;
                    }

                    else if (CheckPad[Temp.node1] < 0) {
                        CheckPad[Temp.node1] = CheckPad[Temp.node2];
                    }

                    else if (CheckPad[Temp.node2] < 0) {
                        CheckPad[Temp.node2] = CheckPad[Temp.node1];
                    }

                    else {
                        if (CheckPad[Temp.node1] < CheckPad[Temp.node2]) {
                            for (i = 0; i < polygons.size(); i++) {
                                if (CheckPad[i] == CheckPad[Temp.node2])
                                    CheckPad[i] = CheckPad[Temp.node2];
                                else
                                    for (j = 0; j < polygons.size(); j++)
                                        if (CheckPad[j] == CheckPad[Temp.node2])
                                            CheckPad[j] = CheckPad[Temp.node2];
                            }
                        }
                        System.out.println(Temp.edge);
                        length += Temp.edge;
                        counter++;
                    }
                }
    }

}

static double ShortestDistance(Polygon polygon1, Polygon polygon2) {
    double shortestdistance = 0;
    double Temporary = 0;
    for (int i = 0; i < polygon1.numberOfVertices; i++)
        for (int j = 0; j < polygon2.numberOfVertices; j++) {
            Temporary = Math.pow(polygon1.points.get(i).x - polygon2.points.get(j).x, 2)
                    + Math.pow(polygon1.points.get(i).y - polygon2.points.get(j).y, 2);
            if (Temporary < shortestdistance)
                shortestdistance = Temporary;
        }
    return Math.sqrt(shortestdistance);

}

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.print("Please enter the name of the file");
    File file = new File(scanner.nextLine());
    try {
        Scanner fileScanner = new Scanner(file);

        int numberOfIslands = Integer.parseInt(fileScanner.nextLine());
        ArrayList<Polygon> polygons = new ArrayList<Polygon>();

        while (fileScanner.hasNext()) {
            String line = fileScanner.nextLine();
            String[] numbers = line.split(" ");
            ArrayList<Point> points = new ArrayList<Point>();
            // PQItem NewItem = new PQItem(Node1, Node2, edge);
            // info.Insert(NewItem);

            for (int i = 1; i < numbers.length; i += 2) {
                Point point = new Point(Integer.parseInt(numbers[i]), Integer.parseInt(numbers[(i + 1)]));

                points.add(point);
            }
            // build tree

            Polygon polygon = new Polygon(points.size(), points);

            polygons.add(polygon);
            // BuildMinSpanTree(numberOfIslands, polygons);

        }

        for (int i = 0; i < polygons.size(); i++) {
            Polygon polygon = polygons.get(i);
            System.out.println(polygon);
        }

        int minimalInterconnect = 0;
        int totalLength = 0;

        System.out.printf("The minimal interconnect consists of %d bridges with a total length of %d",
                minimalInterconnect, totalLength);
    } catch (IOException e) {
        System.out.println(e);
    }
}
</code>```

HERE IS THE SAMPLE PROGRAM
3
4  0  0  0  1  1  1  1  0
4  2  0  2  1  3  1  3  0
3  4  0  5  0  5  1

```<code>public class PriorityQueue {
private Comparable[] HeapArray;
int Last, Limit;
</code>```

PriorityQueue

```<code>public PriorityQueue(int Capacity) {
    HeapArray = new Comparable[Capacity + 1];
    Last = 0;
    Limit = Capacity;
    return;
}
// end constructor

public PriorityQueue() {
    HeapArray = new Comparable[101];
    Last = 0;
    Limit = 100;
    return;
}
// end constructor

public void Insert(Comparable PQI) {
    if (Last == Limit) {
        System.out.println("Priority Queue Overflow!");
        System.exit(0);
    }
    // end if

    HeapArray[++Last] = PQI;
    this.UpHeap(Last);
    return;
}
// end public method Insert

private void UpHeap(int k) {
    Comparable V;

    V = HeapArray[k];

    while (k > 1 && HeapArray[k / 2].compareTo(V) < 0) {
        HeapArray[k] = HeapArray[k / 2];
        k = k / 2;
    }
    // end while

    HeapArray[k] = V;
    return;
}
// end private method UpHeap

public Comparable Remove() {
    Comparable PQI;

    if (Last == 0) {
        System.out.println("Priority Queue Underflow!");
        System.exit(0);
    }
    // end if

    PQI = HeapArray[1];
    HeapArray[1] = HeapArray[Last--];
    this.DownHeap(1);
    return PQI;
}
// end public method Remove

private void DownHeap(int k) {
    Comparable V;
    int j;

    V = HeapArray[k];

    while (k <= Last / 2) {
        j = k + k;

        if (j < Last && HeapArray[j].compareTo(HeapArray[j + 1]) < 0)
            j++;
        // end if

        if (V.compareTo(HeapArray[j]) >= 0)
            break;
        // end if

        HeapArray[k] = HeapArray[j];
        k = j;
    }
    // end while

    HeapArray[k] = V;
    return;
}
// end private method DownHeap

public boolean IsEmpty() {
    if (Last == 0)
        return true;
    else
        return false;
    // end if
}
// end public method IsEmpty

public boolean IsFull() {
    if (Last == Limit)
        return true;
    else
        return false;
    // end if
}
// end public method IsFull

public int Length() {
    return Last;
}
// end public method Length
</code>```

}
// end class PriorityQueue

答:
```<code>Exception in thread "main" java.lang.NumberFormatException: For input string: ""
</code>```

This is self explanatory. The input is expected as number however the input entered is String ""

The line that reads input and expects the value to be interger :

```<code> int numberOfIslands = Integer.parseInt(fileScanner.nextLine());
</code>```

Provide correct input.
Also you could change the .nextLine() to nextInt()

Body:
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at HelloWorld.main(HelloWorld.java:169)

These errors continue to pop up when I run my code against our sample input. We are given a document with polygons and have to use kruskal's algorithm and build a minimal spanning tree to find the shortest distance to each island without creating a cycle. If anyone can help or give advice on how to get rid of these errors that would be great! I dont understand how there can be a numberformatexception on a string ""....

import java.util.Scanner;
import java.util.ArrayList;
import java.io.File;
import java.io.IOException;

public class HelloWorld {
static class Point {
    int x = 0;
    int y = 0;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public String toString() {
        return "(x: " + x + " y: " + y + ")";
    }
}

static class Polygon {
    int numberOfVertices = 0;
    ArrayList<Point> points = new ArrayList<Point>();

    public Polygon(int numberOfVertices, ArrayList<Point> points) {
        this.numberOfVertices = numberOfVertices;
        this.points = points;
    }

    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < points.size(); i++) {
            Point point = this.points.get(i);
            stringBuilder.append(point);
        }

        return stringBuilder.toString();
    }
}

static class PQItem implements Comparable<PQItem> {
    int node1;
    int node2;
    double edge;

    public PQItem(int node1, int node2, double edge) {
        this.node1 = node1;
        this.node2 = node2;
        this.edge = edge;
    }

    public int compareTo(PQItem T) {
        if (edge - T.edge < 0)
            return 1;
        else if (edge - T.edge > 0)
            return -1;
        else
            return 0;
    }

}

public static void BuildMinimalSpanningTree(int numberOfIslands, ArrayList<Polygon> polygons) {
    PriorityQueue q = new PriorityQueue((numberOfIslands * numberOfIslands) / 2);
    PQItem Temp;
    int[] CheckPad = new int[numberOfIslands];
    int FootPrint = 0;
    int counter = 0;
    double length = 0;

    for (int i = 0; i < polygons.size(); i++)
        for (int j = 0; j < polygons.size(); j++) {
            Temp = new PQItem(i, j, ShortestDistance(polygons.get(i), polygons.get(j)));
        }

    for (int i = 0; i < polygons.size(); i++)
        CheckPad[i] = -1 - i;
    while (counter < polygons.size() - 1) {
        Temp = (PQItem) q.Remove();
        for (int i = 0; i < polygons.size(); i++)
            for (int j = 0; j < polygons.size(); j++)
                if (CheckPad[Temp.node1] != CheckPad[Temp.node2]) {
                    if (CheckPad[Temp.node1] < 0 && CheckPad[Temp.node2] < 0) {
                        CheckPad[Temp.node1] = FootPrint;
                        CheckPad[Temp.node2] = FootPrint;
                        FootPrint = FootPrint + 1;
                    }

                    else if (CheckPad[Temp.node1] < 0) {
                        CheckPad[Temp.node1] = CheckPad[Temp.node2];
                    }

                    else if (CheckPad[Temp.node2] < 0) {
                        CheckPad[Temp.node2] = CheckPad[Temp.node1];
                    }

                    else {
                        if (CheckPad[Temp.node1] < CheckPad[Temp.node2]) {
                            for (i = 0; i < polygons.size(); i++) {
                                if (CheckPad[i] == CheckPad[Temp.node2])
                                    CheckPad[i] = CheckPad[Temp.node2];
                                else
                                    for (j = 0; j < polygons.size(); j++)
                                        if (CheckPad[j] == CheckPad[Temp.node2])
                                            CheckPad[j] = CheckPad[Temp.node2];
                            }
                        }
                        System.out.println(Temp.edge);
                        length += Temp.edge;
                        counter++;
                    }
                }
    }

}

static double ShortestDistance(Polygon polygon1, Polygon polygon2) {
    double shortestdistance = 0;
    double Temporary = 0;
    for (int i = 0; i < polygon1.numberOfVertices; i++)
        for (int j = 0; j < polygon2.numberOfVertices; j++) {
            Temporary = Math.pow(polygon1.points.get(i).x - polygon2.points.get(j).x, 2)
                    + Math.pow(polygon1.points.get(i).y - polygon2.points.get(j).y, 2);
            if (Temporary < shortestdistance)
                shortestdistance = Temporary;
        }
    return Math.sqrt(shortestdistance);

}

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.print("Please enter the name of the file");
    File file = new File(scanner.nextLine());
    try {
        Scanner fileScanner = new Scanner(file);

        int numberOfIslands = Integer.parseInt(fileScanner.nextLine());
        ArrayList<Polygon> polygons = new ArrayList<Polygon>();

        while (fileScanner.hasNext()) {
            String line = fileScanner.nextLine();
            String[] numbers = line.split(" ");
            ArrayList<Point> points = new ArrayList<Point>();
            // PQItem NewItem = new PQItem(Node1, Node2, edge);
            // info.Insert(NewItem);

            for (int i = 1; i < numbers.length; i += 2) {
                Point point = new Point(Integer.parseInt(numbers[i]), Integer.parseInt(numbers[(i + 1)]));

                points.add(point);
            }
            // build tree

            Polygon polygon = new Polygon(points.size(), points);

            polygons.add(polygon);
            // BuildMinSpanTree(numberOfIslands, polygons);

        }

        for (int i = 0; i < polygons.size(); i++) {
            Polygon polygon = polygons.get(i);
            System.out.println(polygon);
        }

        int minimalInterconnect = 0;
        int totalLength = 0;

        System.out.printf("The minimal interconnect consists of %d bridges with a total length of %d",
                minimalInterconnect, totalLength);
    } catch (IOException e) {
        System.out.println(e);
    }
}

HERE IS THE SAMPLE PROGRAM
3
4  0  0  0  1  1  1  1  0
4  2  0  2  1  3  1  3  0
3  4  0  5  0  5  1

public class PriorityQueue {
private Comparable[] HeapArray;
int Last, Limit;

PriorityQueue

public PriorityQueue(int Capacity) {
    HeapArray = new Comparable[Capacity + 1];
    Last = 0;
    Limit = Capacity;
    return;
}
// end constructor

public PriorityQueue() {
    HeapArray = new Comparable[101];
    Last = 0;
    Limit = 100;
    return;
}
// end constructor

public void Insert(Comparable PQI) {
    if (Last == Limit) {
        System.out.println("Priority Queue Overflow!");
        System.exit(0);
    }
    // end if

    HeapArray[++Last] = PQI;
    this.UpHeap(Last);
    return;
}
// end public method Insert

private void UpHeap(int k) {
    Comparable V;

    V = HeapArray[k];

    while (k > 1 && HeapArray[k / 2].compareTo(V) < 0) {
        HeapArray[k] = HeapArray[k / 2];
        k = k / 2;
    }
    // end while

    HeapArray[k] = V;
    return;
}
// end private method UpHeap

public Comparable Remove() {
    Comparable PQI;

    if (Last == 0) {
        System.out.println("Priority Queue Underflow!");
        System.exit(0);
    }
    // end if

    PQI = HeapArray[1];
    HeapArray[1] = HeapArray[Last--];
    this.DownHeap(1);
    return PQI;
}
// end public method Remove

private void DownHeap(int k) {
    Comparable V;
    int j;

    V = HeapArray[k];

    while (k <= Last / 2) {
        j = k + k;

        if (j < Last && HeapArray[j].compareTo(HeapArray[j + 1]) < 0)
            j++;
        // end if

        if (V.compareTo(HeapArray[j]) >= 0)
            break;
        // end if

        HeapArray[k] = HeapArray[j];
        k = j;
    }
    // end while

    HeapArray[k] = V;
    return;
}
// end private method DownHeap

public boolean IsEmpty() {
    if (Last == 0)
        return true;
    else
        return false;
    // end if
}
// end public method IsEmpty

public boolean IsFull() {
    if (Last == Limit)
        return true;
    else
        return false;
    // end if
}
// end public method IsFull

public int Length() {
    return Last;
}
// end public method Length

}
// end class PriorityQueue

Body:
Exception in thread "main" java.lang.NumberFormatException: For input string: ""

This is self explanatory. The input is expected as number however the input entered is String ""

The line that reads input and expects the value to be interger :

 int numberOfIslands = Integer.parseInt(fileScanner.nextLine());

Provide correct input.
Also you could change the .nextLine() to nextInt()


问:
Rails Webpacker and stage-2 class transform properties not working
I'm trying out Webpacker on a new Rails application to get familiar with it and I can't get it to compile my javascript code.

Here's the code:

```<code>import React, { Component, PropTypes } from 'react'
import DayPicker, { DateUtils } from 'react-day-picker'
import 'react-day-picker/lib/style.css'

export default class Example extends Component {
  constructor(props) {
    super(props)
    this.state = {
      selectedDays: []
    }
  }

  handleDayClick = (day, selected) => {
    console.log(day)
  }

  render() {
    return (
      <p>Test</p>
    )
  }
}

20:05:21 hot.1  | ERROR in ./app/javascript/packs/components/example/example.jsx
20:05:21 hot.1  | Module build failed: SyntaxError: Missing class properties transform.
20:05:21 hot.1  |
20:05:21 hot.1  |   11 |   }
20:05:21 hot.1  |   12 |
20:05:21 hot.1  | > 13 |   handleDayClick = (day, selected) => {
20:05:21 hot.1  |      |   ^
</code>```

This is on a brand new Rails app using the latest Webpacker gem from github.

My .babelrc:

```<code>{
  "presets": ["env", "es2015", "react", "stage-2"]
}
</code>```

My devDependencies are:

```<code>"devDependencies": {
  "babel-preset-es2015": "^6.24.0",
  "babel-preset-stage-2": "^6.22.0",
  "webpack-dev-server": "^2.4.2"
}
</code>```

According to this Babel REPL link,  this should be working. https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&targets=&browsers=&builtIns=false&experimental=true&loose=false&spec=false&code=class%20PostInfo%20extends%20React.Component%20%7B%0A%09handleOptionsButtonClick%20%3D%20(e)%20%3D%3E%20%7B%0A%20%20%20%20this.setState(%7BshowOptionsModal%3A%20true%7D)%3B%0A%20%20%7D%0A%7D

Any ideas?

答:
To fix, I had to add the presets to the individual loader files, specifically.

```<code>// config/webpack/loaders/babel.js
module.exports = {
  test: /\.js(\.erb)?$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    presets: [
      'es2015',
      'stage-2'
    ]
  }
}

// config/webpack/loaders/react.js
module.exports = {
  test: /\.(js|jsx)?(\.erb)?$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    presets: [
      'es2015',
      'react',
      'stage-2'
    ]
  }
}
</code>```

Now I can use the nice shorthand arrow class functions.

Body:
I'm trying out Webpacker on a new Rails application to get familiar with it and I can't get it to compile my javascript code.

Here's the code:

import React, { Component, PropTypes } from 'react'
import DayPicker, { DateUtils } from 'react-day-picker'
import 'react-day-picker/lib/style.css'

export default class Example extends Component {
  constructor(props) {
    super(props)
    this.state = {
      selectedDays: []
    }
  }

  handleDayClick = (day, selected) => {
    console.log(day)
  }

  render() {
    return (

Test

    )
  }
}

20:05:21 hot.1  | ERROR in ./app/javascript/packs/components/example/example.jsx
20:05:21 hot.1  | Module build failed: SyntaxError: Missing class properties transform.
20:05:21 hot.1  |
20:05:21 hot.1  |   11 |   }
20:05:21 hot.1  |   12 |
20:05:21 hot.1  | > 13 |   handleDayClick = (day, selected) => {
20:05:21 hot.1  |      |   ^

This is on a brand new Rails app using the latest Webpacker gem from github.

My .babelrc:

{
  "presets": ["env", "es2015", "react", "stage-2"]
}

My devDependencies are:

"devDependencies": {
  "babel-preset-es2015": "^6.24.0",
  "babel-preset-stage-2": "^6.22.0",
  "webpack-dev-server": "^2.4.2"
}

According to this Babel REPL link,  this should be working. https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&targets=&browsers=&builtIns=false&experimental=true&loose=false&spec=false&code=class%20PostInfo%20extends%20React.Component%20%7B%0A%09handleOptionsButtonClick%20%3D%20(e)%20%3D%3E%20%7B%0A%20%20%20%20this.setState(%7BshowOptionsModal%3A%20true%7D)%3B%0A%20%20%7D%0A%7D

Any ideas?

Body:
To fix, I had to add the presets to the individual loader files, specifically.

// config/webpack/loaders/babel.js
module.exports = {
  test: /\.js(\.erb)?$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    presets: [
      'es2015',
      'stage-2'
    ]
  }
}

// config/webpack/loaders/react.js
module.exports = {
  test: /\.(js|jsx)?(\.erb)?$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    presets: [
      'es2015',
      'react',
      'stage-2'
    ]
  }
}

Now I can use the nice shorthand arrow class functions.


问:
How do you get the length of a list in the JSF expression language?
How would I get the length of an ArrayList using a JSF EL expression?

```<code>#{MyBean.somelist.length}
</code>```

does not work.

答:
After 7 years... the facelets solution still works fine for me as a jsf user

include the namespace as
xmlns:fn="http://java.sun.com/jsp/jstl/functions"

and use the EL as
#{fn:length(myBean.someList)} for example if using in jsf ui:fragment below example works fine

```<code><ui:fragment rendered="#{fn:length(myBean.someList) gt 0}">
    <!-- Do something here-->
</ui:fragment>
</code>```

OwnerDisplayName: Greg

Body:
How would I get the length of an ArrayList using a JSF EL expression?

#{MyBean.somelist.length}

does not work.

Body:
After 7 years... the facelets solution still works fine for me as a jsf user

include the namespace as
xmlns:fn="http://java.sun.com/jsp/jstl/functions"

and use the EL as
#{fn:length(myBean.someList)} for example if using in jsf ui:fragment below example works fine

<ui:fragment rendered="#{fn:length(myBean.someList) gt 0}">
    <!-- Do something here-->
</ui:fragment>


问:
How to return a string generated from a sha1 bytearray to that bytearray?
first of all sorry for the bad English.

Well, I want to read the pieces hashes information from a torrent file. Currently, I'm using https://github.com/hyPiRion/java-bencode this bencode library to decode the information, but my problem is when I want to convert the string of pieces to a byte array.
The torrent file is encoded in UTF-8. but If I do

```<code> Byte[] bytepieces = piecestring.getBytes("UTF-8");
</code>```

It gives well. anything really usable.

For other side, for comparing or try to get the string, instead of getting the bytes, I've read the first piece of my file, and calculate the sha1. After getting the 20 sized byte array of sha1 if I convert it to string, effectively, the string matches the first part of the big string of pieces... But well, If I try to return that generated string, to the 20 originally bytes that created it ... I can't... how to do this?

Little example:

```<code>FileInputStream fin = new FileInputStream("miFile");
byte[] array = new Byte[512*1024]; //a piece of 512 kb
fin.read(array,0,512*1024);
MessageDigest md = MessageDigest.getInstanse ("SHA);
Byte [ sha1byte = md.digest(array);
String s = new String(sha1byte,"UTF-8");
</code>```

After doing this, sha1byte.length is 20, and is OK, the correct size of a sha1 hash. But if i do
s.getBytes("UTF-8").length, in the case of my example i got... ¡33! ¡wuuut! I want to get again from the generated string my 20 arrays. How to can I get this?

Well thanks :P

答:
Thanks guys for your answer, but I can find the solution using this https://github.com/bedeho/bencodej

The lib loads the Bencode data alwais as bytearray with custom classes, and is able have a 1:1 with the bytestrings :p
Thanks for all.

Body:
first of all sorry for the bad English.

Well, I want to read the pieces hashes information from a torrent file. Currently, I'm using https://github.com/hyPiRion/java-bencode this bencode library to decode the information, but my problem is when I want to convert the string of pieces to a byte array.
The torrent file is encoded in UTF-8. but If I do

 Byte[] bytepieces = piecestring.getBytes("UTF-8");

It gives well. anything really usable.

For other side, for comparing or try to get the string, instead of getting the bytes, I've read the first piece of my file, and calculate the sha1. After getting the 20 sized byte array of sha1 if I convert it to string, effectively, the string matches the first part of the big string of pieces... But well, If I try to return that generated string, to the 20 originally bytes that created it ... I can't... how to do this?

Little example:

FileInputStream fin = new FileInputStream("miFile");
byte[] array = new Byte[512*1024]; //a piece of 512 kb
fin.read(array,0,512*1024);
MessageDigest md = MessageDigest.getInstanse ("SHA);
Byte [ sha1byte = md.digest(array);
String s = new String(sha1byte,"UTF-8");

After doing this, sha1byte.length is 20, and is OK, the correct size of a sha1 hash. But if i do
s.getBytes("UTF-8").length, in the case of my example i got... ¡33! ¡wuuut! I want to get again from the generated string my 20 arrays. How to can I get this?

Well thanks :P


问:
Get the list of child if the selected value is same value as in the Firebase database value
My database is as following :

```<code>List_of_users>
             sunil dhakal>
                        departmnet:"Computer Science",
                        level:"Level 3 Undergraduate",
                        name:"sunil dhakal",
                        student_id:"1412361",
                        username:"1412361@my.brunel.ac.uk",
</code>```

```<code>root.child("List_of_user").addValueEventListener(new ValueEventListener() {

    public void onDataChange(DataSnapshot dataSnapshot) {
        for (DataSnapshot data :dataSnapshot.getChildren()){
            if (data.child(department).exists()&& data.child(level).exists()){
                Set<String> set = new HashSet<String>();
                Iterator i = dataSnapshot.child("List_of_users").getChildren().iterator();
                while (i.hasNext()) {
                    set.add(((DataSnapshot) i.next()).getKey());
                }
                list_of_rooms.clear();
                list_of_rooms.addAll(set);
                arrayAdapter.notifyDataSetChanged();
            }
            else{
                Toast.makeText(searchuser.this,"There is not user with the department and level that was selected",Toast.LENGTH_SHORT).show();
                return;
            }
        }
    }

    public void onCancelled(DatabaseError databaseError) {}
});
</code>```

I have a spinner where user is able to select department and level and click a button which list all the user in the database with that department and level.

答:
Use a firebase query to get them:

```<code>firebaseReference.child("List_of_users")
                 .orderByChild("department")
                 .equalTo("valueInSpinner")
                 .orderByChild("level")
                 .equalTo("valueInSpinner")
</code>```

Then you could use that with an Adapter to bind it to a ListView.

Hope this helps.

Body:
My database is as following :

List_of_users>
             sunil dhakal>
                        departmnet:"Computer Science",
                        level:"Level 3 Undergraduate",
                        name:"sunil dhakal",
                        student_id:"1412361",
                        username:"1412361@my.brunel.ac.uk",

root.child("List_of_user").addValueEventListener(new ValueEventListener() {

    public void onDataChange(DataSnapshot dataSnapshot) {
        for (DataSnapshot data :dataSnapshot.getChildren()){
            if (data.child(department).exists()&& data.child(level).exists()){
                Set<String> set = new HashSet<String>();
                Iterator i = dataSnapshot.child("List_of_users").getChildren().iterator();
                while (i.hasNext()) {
                    set.add(((DataSnapshot) i.next()).getKey());
                }
                list_of_rooms.clear();
                list_of_rooms.addAll(set);
                arrayAdapter.notifyDataSetChanged();
            }
            else{
                Toast.makeText(searchuser.this,"There is not user with the department and level that was selected",Toast.LENGTH_SHORT).show();
                return;
            }
        }
    }

    public void onCancelled(DatabaseError databaseError) {}
});

I have a spinner where user is able to select department and level and click a button which list all the user in the database with that department and level.

Body:
Use a firebase query to get them:

firebaseReference.child("List_of_users")
                 .orderByChild("department")
                 .equalTo("valueInSpinner")
                 .orderByChild("level")
                 .equalTo("valueInSpinner")

Then you could use that with an Adapter to bind it to a ListView.

Hope this helps.


问:
VBA Sum a Variable Range With Non-Empty Cells and Looping through array
I'm working on a large data reformatting macro. I'm taking an upload sheet with a variety of data and making a whole new workbook into something that gets sent to external users. I've gotten it pretty close to "click this button to generate," except this last part.

Column F has numbers, maybe duplicates, maybe not. IF column F has duplicates, I want it to sum the corresponding amounts in column G and output in the last (H,#). Then it needs to go to the next data and test for duplicates there. It also will put the borders around it, though that's not the hard part.

It should test from ws1.Range("F5") To ws1.Range("F"& lRow + 5), which is has been identified earlier on.

Because it is pulling lRow from the upload data, that's probably the easiest way to identify the end-point, though lRow +1 will is an empty row. But for summing, there will likely always be data in the next row, so scanning for empty cells doesn't help.

Image of excel sheet

I was trying to do it with a while statement, but I couldn't figure out how to do the 'testing loop' for duplicates as part of the larger scan of the entire table.

```<code>Let i = 5
While i < lRow + 5
    If ws1.Cells(i, 6) = ws1.Cells(i + 1, 6) Then
        Let CopyRange = ws1.Cells(i, 7) & ":" & ws1.Cells(i + 1, 7)
        Let PasteRange = ws1.Cells(i + 1, 8)
        ws1.Range(PasteRange).Formula = "=Sum(CopyRange)"
    i = i + 1

    End If
Wend
</code>```

I'm really not sure the best way to approach.

Thank you for any insight!

Edit:

Here is another link to the most similar problem I've seen, but it's slightly different: Similar

Here is my code, in full, for any review, but it's quite lengthy and this is at the very bottom of it, so I'm not sure it creates any value:

```<code>Sub ConvertToFundingRequest()

Dim wb As Workbook, og As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet, os As Worksheet, os2 As Worksheet, os3 As Worksheet
Dim lRow As Long, i As Long, endRow As Long, lastSearch1 As Long, lastSearch2 As Long, lastSearch3 As Long, first As Long, last As Long
Dim CopyRange As String, PasteRange As String, searchValue As String

'Create the new workbook
Set og = ThisWorkbook
Set os = og.Worksheets("Upload Sheet")
Set os2 = og.Worksheets("Instructions")
Set os3 = og.Worksheets("Vendors")
Set wb = Workbooks.Add
wb.Worksheets.Add

Application.DisplayAlerts = False
'wb.Sheets("Sheet2").Delete
'wb.Sheets("Sheet3").Delete
Application.DisplayAlerts = True

Set ws1 = wb.Worksheets(1)
Set ws2 = wb.Worksheets(2)

Application.ScreenUpdating = False
ws2.Activate
ActiveWindow.Zoom = 85
ws1.Activate
ActiveWindow.Zoom = 85
Application.ScreenUpdating = True

ws1.Name = "Funding in Total"
ws2.Name = "Funding by Property"

'Format the cells to look like funding request
ws1.Columns("A").ColumnWidth = 38
ws1.Columns("B").ColumnWidth = 55
ws1.Columns("C:E").ColumnWidth = 13
ws1.Columns("F").ColumnWidth = 21
ws1.Columns("G").ColumnWidth = 16
ws1.Columns("H").ColumnWidth = 13
ws1.Columns("I").ColumnWidth = 9
ws1.Rows("1").RowHeight = 27
ws1.Range("A1:B1").Merge
    ws1.Range("A1").Font.Size = 12
    ws1.Range("A1").Font.Name = "Calibri"
    ws1.Range("A1").Font.FontStyle = "Bold"
ws1.Range("C1:G1").Merge
    ws1.Range("C1:G1").Font.Size = 20
    ws1.Range("C1:G1").Font.Name = "Calibri"
    ws1.Range("C1:G1").Font.FontStyle = "Bold"
    ws1.Range("C1:G1").Borders.LineStyle = xlContinuous
    ws1.Range("C1:G1").Borders.Weight = xlMedium
    ws1.Range("C1:G1").HorizontalAlignment = xlCenter
    ws1.Range("C1:G1").Interior.Color = RGB(255, 255, 153)
'Create the table title formatting
    ws1.Range("A4:H4").Font.Underline = xlUnderlineStyleSingle
    ws1.Range("A4:H4").Font.Size = 12
    ws1.Range("A4:H4").Font.Name = "Calibri"
    ws1.Range("A4:H4").Font.FontStyle = "Bold"
    ws1.Range("H3").Font.Size = 12
    ws1.Range("H3").Font.Name = "Calibri"
    ws1.Range("H3").Font.FontStyle = "Bold"

'Create those headers with the formatting
ws1.Cells(1, 1).Value = "Church Street Funding Request " & Format(Now(), "mmmm dd, yyyy")
ws1.Cells(1, 3).Value = "In Total"
ws1.Cells(3, 8).Value = "Invoice"
ws1.Cells(4, 1).Value = "Vendor"
ws1.Cells(4, 2).Value = "Invoice Notes"
ws1.Cells(4, 3).Value = "Property"
ws1.Cells(4, 4).Value = "Date"
ws1.Cells(4, 5).Value = "Account"
ws1.Cells(4, 6).Value = "Invoice Number"
ws1.Cells(4, 7).Value = "Amount"
ws1.Cells(4, 8).Value = "Total"

'Build out data array from original worksheet
lRow = os.Cells(Rows.Count, 1).End(xlUp).Row 'identifies last row to copy data from
'Copy Vendor Codes
Let CopyRange = "C2:C" & lRow + 1
Let PasteRange = "A5:A" & lRow + 5
os3.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy Invoice Date
Let CopyRange = "E1:E" & lRow
Let PasteRange = "D5:D" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).NumberFormat = "m/d/yyyy;@"
'Copy Invoices Notes
Let CopyRange = "H1:H" & lRow
Let PasteRange = "B5:B" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy Property Code
Let CopyRange = "I1:I" & lRow
Let PasteRange = "C5:C" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy Invoice Number
Let CopyRange = "G1:G" & lRow
Let PasteRange = "F5:F" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy GL Account
Let CopyRange = "K1:K" & lRow
Let PasteRange = "E5:E" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Replace what:="-", Replacement:="", LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
'Copy Amount
Let CopyRange = "J1:J" & lRow
Let PasteRange = "G5:G" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
'Copy Segment
Let CopyRange = "V1:V" & lRow
Let PasteRange = "I5:I" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Format the bottom part of funding request where the totals are
Let PasteRange = "C" & lRow + 6 & ":F" & lRow + 6
ws1.Range(PasteRange).Merge
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Value = "TOTAL VENDOR PAYMENTS"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(255, 255, 0)

Let PasteRange = "C" & lRow + 12 & ":F" & lRow + 12
ws1.Range(PasteRange).Merge
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Value = "TOTAL TO BE PAID OTHER"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(255, 255, 0)

Let PasteRange = "C" & lRow + 15 & ":F" & lRow + 15
ws1.Range(PasteRange).Merge
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Value = "TOTAL FUNDING REQUEST"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlDouble
    ws1.Range(PasteRange).Interior.Color = RGB(255, 255, 0)

Let PasteRange = "B" & lRow + 15 & ":B" & lRow + 15
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlDouble

Let PasteRange = "G" & lRow + 6 'Summing the Amounts
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Formula = "=SUM(G5:G" & lRow + 5 & ")"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(197, 217, 241)

Let PasteRange = "G" & lRow + 12 'Summing Sales Tax/Other
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Formula = "=SUM(G" & lRow + 8 & ":G" & lRow + 10 & ")"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"

Let PasteRange = "G" & lRow + 15 'Grand Sum
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Formula = "=SUM(G" & lRow + 6 & "+G" & lRow + 12 & ")"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlDouble
    ws1.Range(PasteRange).Interior.Color = RGB(197, 217, 241)

'This completes all the base formatting for the Funding Request
'''''''''''''''''''''
'Lets start to modify the data. We'll start with the second sheet.

'Again, starting with Formatting
'Format the cells to look like funding request
ws2.Columns("A").ColumnWidth = 38
ws2.Columns("B").ColumnWidth = 55
ws2.Columns("C:E").ColumnWidth = 13
ws2.Columns("F").ColumnWidth = 21
ws2.Columns("G").ColumnWidth = 16
ws2.Rows("1").RowHeight = 27
ws2.Range("A1:B1").Merge
    ws2.Range("A1").Font.Size = 12
    ws2.Range("A1").Font.Name = "Calibri"
    ws2.Range("A1").Font.FontStyle = "Bold"
ws2.Range("C1:G1").Merge
    ws2.Range("C1:G1").Font.Size = 20
    ws2.Range("C1:G1").Font.Name = "Calibri"
    ws2.Range("C1:G1").Font.FontStyle = "Bold"
    ws2.Range("C1:G1").Borders.LineStyle = xlContinuous
    ws2.Range("C1:G1").Borders.Weight = xlMedium
    ws2.Range("C1:G1").HorizontalAlignment = xlCenter
    ws2.Range("C1:G1").Interior.Color = RGB(255, 255, 153)
'Create the table title formatting
    ws2.Range("A3:G3").Font.Underline = xlUnderlineStyleSingle
    ws2.Range("A3:G3").Font.Size = 12
    ws2.Range("A3:G3").Font.Name = "Calibri"
    ws2.Range("A3:G3").Font.FontStyle = "Bold"
    ws2.Range("A3:G3").Borders(xlEdgeBottom).LineStyle = xlContinuous

'Create those headers with the formatting
ws2.Cells(1, 1).Value = "Church Street Funding Request " & Format(Now(), "mmmm dd, yyyy")
ws2.Cells(1, 3).Value = "By Property"
ws2.Cells(3, 1).Value = "Vendor"
ws2.Cells(3, 2).Value = "Invoice Notes"
ws2.Cells(3, 3).Value = "Property"
ws2.Cells(3, 4).Value = "Date"
ws2.Cells(3, 5).Value = "Account"
ws2.Cells(3, 6).Value = "Invoice Number"
ws2.Cells(3, 7).Value = "Amount"

'Copy Data
Let CopyRange = "A5:G" & lRow + 5
Let PasteRange = "A5:G" & lRow + 5
ws1.Range(CopyRange).Copy
ws2.Range(PasteRange).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"

'Sort Data
ws2.Range("C4").Value = "Site"
    ws2.Range("A4:G4").AutoFilter
    ws2.AutoFilter.Sort.SortFields. _
        Clear
    ws2.AutoFilter.Sort.SortFields. _
        Add Key:=Range("C4"), SortOn:=xlSortOnValues, Order:=xlAscending, _
        DataOption:=xlSortNormal
    With ws2.AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    ws2.Range("A4:G4").AutoFilter
ws2.Range("C4").Value = ""

'Find where -02 ends and label
searchValue = "2350-02"
    With ws2
        endRow = .Cells(Rows.Count, 3).End(xlUp).Row
        For i = 1 To endRow
            If .Cells(i + 4, 3) = searchValue Then
                lastSearch1 = i
            End If
        Next i
    End With

Let PasteRange = lastSearch1 + 5 & ":" & lastSearch1 + 7
ws2.Rows(PasteRange).EntireRow.Insert
Let PasteRange = "B" & lastSearch1 + 6 & ":G" & lastSearch1 + 6
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch1 + 6
        ws2.Range(PasteRange).Value = "Total 2350-02"
    Let PasteRange = "G" & lastSearch1 + 6
        ws2.Range(PasteRange).Formula = "=Sum(G5:G" & lastSearch1 + 5 & ")"

'Find where -03 ends and label
searchValue = "2350-03"
    With ws2
        endRow = .Cells(Rows.Count, 3).End(xlUp).Row
        For i = 1 To endRow
            If .Cells(i + lastSearch1 + 7, 3) = searchValue Then
                lastSearch2 = i + lastSearch1 + 7
            End If
        Next i
    End With

Let PasteRange = lastSearch2 + 1 & ":" & lastSearch2 + 3
ws2.Rows(PasteRange).EntireRow.Insert
Let PasteRange = "B" & lastSearch2 + 2 & ":G" & lastSearch2 + 2
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch2 + 2
        ws2.Range(PasteRange).Value = "Total 2350-03"
    Let PasteRange = "G" & lastSearch2 + 2
        ws2.Range(PasteRange).Formula = "=Sum(G" & lastSearch1 + 8 & ":G" & lastSearch2 + 1 & ")"

'Find where -04 ends and label
searchValue = "2350-04"
    With ws2
        endRow = .Cells(Rows.Count, 3).End(xlUp).Row
        For i = 1 To endRow
            If .Cells(i + lastSearch2 + 4, 3) = searchValue Then
                lastSearch3 = i + lastSearch2 + 4
            End If
        Next i
    End With

Let PasteRange = lastSearch3 + 1 & ":" & lastSearch3 + 3
ws2.Rows(PasteRange).EntireRow.Insert
Let PasteRange = "B" & lastSearch3 + 2 & ":G" & lastSearch3 + 2
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch3 + 2
        ws2.Range(PasteRange).Value = "Total 2350-04"
    Let PasteRange = "G" & lastSearch3 + 2
        ws2.Range(PasteRange).Formula = "=Sum(G" & lastSearch2 + 4 & ":G" & lastSearch3 + 1 & ")"

'Finish off The by Property Tab
Let PasteRange = "A" & lastSearch3 + 4 & ":G" & lastSearch3 + 4
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch3 + 4
        ws2.Range(PasteRange).Value = "Total Funding Request"
    Let PasteRange = "G" & lastSearch3 + 4
        ws2.Range(PasteRange).Formula = "=Sum(G" & lastSearch1 + 6 & " + G" & lastSearch2 + 2 & " + G" & lastSearch3 + 2 & ")"

'The property tab should now be completely formatted (except Sales Tax, which is a manual entry
''''''''''''''''''
'Only thing remaining is to do the combined invoices thing.

Let i = 5
'While i < lRow + 5
    If ws1.Cells(i, 6) = ws1.Cells(i + 1, 6) Then 'And ws1.Cells(i, 6) = ws1.Cells(i + 2, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 3, 6) And _
    'ws1.Cells(i, 6) = ws1.Cells(i + 4, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 5, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 6, 6) And _
    'ws1.Cells(i, 6) = ws1.Cells(i + 7, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 8, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 9, 6) Then
        Let CopyRange = ws1.Cells(i, 7) & ":" & ws1.Cells(i + 1, 7)
        Let PasteRange = ws1.Cells(i + 1, 8)
        ws1.Range(PasteRange).Value = CopyRange
    i = i + 1
'
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then

    End If
'Wend

ws2.Range("Z1").Copy
End Sub
</code>```

Edit 2: The other post I linked is the process I want, but I would need a follow-up to delete all the non-final values, which include any non-duplicate invoices as well as the first iterations of the duplicates (meaning if it prints 11,518.70 in H5:H10, i'd need to clear H5:H9). I also don't know how I'd format the boxes using this way.

Edit 3:

Here is my partial solution. The only thing this doesn't accomplish (and I don't know how), is to create the boxes around the invoices which belong together.

```<code>'Only thing remaining is to do the combined invoices thing.

    With ws1.Range("H5:H" & lRow + 4)
        .ClearContents
        .Value = ws1.Evaluate("INDEX(SUMIF(F5:F" & lRow + 4 & ",F5:F" & lRow + 4 & ",G5:G" & lRow + 4 & "),)")
    End With

    i = 5
    For i = 5 To lRow + 4
        If ws1.Cells(i, 7).Value = ws1.Cells(i, 8).Value Then
            ws1.Cells(i, 8).Value = ""
        End If
    Next i

    i = 5
    For i = 5 To lRow + 4
        If ws1.Cells(i, 8).Value = ws1.Cells(i + 1, 8).Value Then
            ws1.Cells(i, 8).Value = ""
        End If
    Next i
    Let PasteRange = "H5:H" & lRow + 4
    ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
</code>```

答:
Alright, for anyone who has a similar problem, here was my solution. I created an exhaustive solution set based on if there were duplicate values, and had different border stipulations for each. I'm sure it's not the fastest way, but now I have a deliverable.</p>

```<code>'Only thing remaining is to do the combined invoices thing.

With ws1.Range("H5:H" & lRow + 4)
    .ClearContents
    .Value = ws1.Evaluate("INDEX(SUMIF(F5:F" & lRow + 4 & ",F5:F" & lRow + 4 & ",G5:G" & lRow + 4 & "),)")
End With

Let PasteRange = "G5:H" & lRow + 4
ws1.Range(PasteRange).Borders.LineStyle = xlContinuous

i = 5
For i = 5 To lRow + 4
    If ws1.Cells(i, 7).Value = ws1.Cells(i, 8).Value Then
        ws1.Cells(i, 8).Value = ""
        ws1.Cells(i, 8).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 8).Borders(xlEdgeRight).LineStyle = xlNone
        ws1.Cells(i, 8).Borders(xlEdgeLeft).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeRight).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeLeft).LineStyle = xlNone
    End If
Next i

i = 5
For i = 5 To lRow + 4
    If ws1.Cells(i, 8).Value = ws1.Cells(i + 1, 8).Value Then
        ws1.Cells(i, 8).Value = ""
        ws1.Cells(i, 8).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 8).Borders(xlEdgeLeft).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeRight).LineStyle = xlNone
        ws1.Cells(i + 1, 8).Borders(xlEdgeLeft).LineStyle = xlNone
        ws1.Cells(i + 1, 7).Borders(xlEdgeRight).LineStyle = xlNone
    End If
Next i

i = 5
For i = 5 To lRow + 4
    If ws1.Cells(i, 6).Value <> ws1.Cells(i - 1, 6).Value And ws1.Cells(i, 6).Value = ws1.Cells(i + 1, 6).Value Then
        ws1.Cells(i, 8).Borders(xlEdgeTop).LineStyle = xlContinuous
        ws1.Cells(i, 7).Borders(xlEdgeTop).LineStyle = xlContinuous
    End If
Next i

ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
</code>```

Body:
I'm working on a large data reformatting macro. I'm taking an upload sheet with a variety of data and making a whole new workbook into something that gets sent to external users. I've gotten it pretty close to "click this button to generate," except this last part.

Column F has numbers, maybe duplicates, maybe not. IF column F has duplicates, I want it to sum the corresponding amounts in column G and output in the last (H,#). Then it needs to go to the next data and test for duplicates there. It also will put the borders around it, though that's not the hard part.

It should test from ws1.Range("F5") To ws1.Range("F"& lRow + 5), which is has been identified earlier on.

Because it is pulling lRow from the upload data, that's probably the easiest way to identify the end-point, though lRow +1 will is an empty row. But for summing, there will likely always be data in the next row, so scanning for empty cells doesn't help.

Image of excel sheet

I was trying to do it with a while statement, but I couldn't figure out how to do the 'testing loop' for duplicates as part of the larger scan of the entire table.

Let i = 5
While i < lRow + 5
    If ws1.Cells(i, 6) = ws1.Cells(i + 1, 6) Then
        Let CopyRange = ws1.Cells(i, 7) & ":" & ws1.Cells(i + 1, 7)
        Let PasteRange = ws1.Cells(i + 1, 8)
        ws1.Range(PasteRange).Formula = "=Sum(CopyRange)"
    i = i + 1

    End If
Wend

I'm really not sure the best way to approach.

Thank you for any insight!

Edit:

Here is another link to the most similar problem I've seen, but it's slightly different: Similar

Here is my code, in full, for any review, but it's quite lengthy and this is at the very bottom of it, so I'm not sure it creates any value:

Sub ConvertToFundingRequest()

Dim wb As Workbook, og As Workbook
Dim ws1 As Worksheet, ws2 As Worksheet, os As Worksheet, os2 As Worksheet, os3 As Worksheet
Dim lRow As Long, i As Long, endRow As Long, lastSearch1 As Long, lastSearch2 As Long, lastSearch3 As Long, first As Long, last As Long
Dim CopyRange As String, PasteRange As String, searchValue As String

'Create the new workbook
Set og = ThisWorkbook
Set os = og.Worksheets("Upload Sheet")
Set os2 = og.Worksheets("Instructions")
Set os3 = og.Worksheets("Vendors")
Set wb = Workbooks.Add
wb.Worksheets.Add

Application.DisplayAlerts = False
'wb.Sheets("Sheet2").Delete
'wb.Sheets("Sheet3").Delete
Application.DisplayAlerts = True

Set ws1 = wb.Worksheets(1)
Set ws2 = wb.Worksheets(2)

Application.ScreenUpdating = False
ws2.Activate
ActiveWindow.Zoom = 85
ws1.Activate
ActiveWindow.Zoom = 85
Application.ScreenUpdating = True

ws1.Name = "Funding in Total"
ws2.Name = "Funding by Property"

'Format the cells to look like funding request
ws1.Columns("A").ColumnWidth = 38
ws1.Columns("B").ColumnWidth = 55
ws1.Columns("C:E").ColumnWidth = 13
ws1.Columns("F").ColumnWidth = 21
ws1.Columns("G").ColumnWidth = 16
ws1.Columns("H").ColumnWidth = 13
ws1.Columns("I").ColumnWidth = 9
ws1.Rows("1").RowHeight = 27
ws1.Range("A1:B1").Merge
    ws1.Range("A1").Font.Size = 12
    ws1.Range("A1").Font.Name = "Calibri"
    ws1.Range("A1").Font.FontStyle = "Bold"
ws1.Range("C1:G1").Merge
    ws1.Range("C1:G1").Font.Size = 20
    ws1.Range("C1:G1").Font.Name = "Calibri"
    ws1.Range("C1:G1").Font.FontStyle = "Bold"
    ws1.Range("C1:G1").Borders.LineStyle = xlContinuous
    ws1.Range("C1:G1").Borders.Weight = xlMedium
    ws1.Range("C1:G1").HorizontalAlignment = xlCenter
    ws1.Range("C1:G1").Interior.Color = RGB(255, 255, 153)
'Create the table title formatting
    ws1.Range("A4:H4").Font.Underline = xlUnderlineStyleSingle
    ws1.Range("A4:H4").Font.Size = 12
    ws1.Range("A4:H4").Font.Name = "Calibri"
    ws1.Range("A4:H4").Font.FontStyle = "Bold"
    ws1.Range("H3").Font.Size = 12
    ws1.Range("H3").Font.Name = "Calibri"
    ws1.Range("H3").Font.FontStyle = "Bold"

'Create those headers with the formatting
ws1.Cells(1, 1).Value = "Church Street Funding Request " & Format(Now(), "mmmm dd, yyyy")
ws1.Cells(1, 3).Value = "In Total"
ws1.Cells(3, 8).Value = "Invoice"
ws1.Cells(4, 1).Value = "Vendor"
ws1.Cells(4, 2).Value = "Invoice Notes"
ws1.Cells(4, 3).Value = "Property"
ws1.Cells(4, 4).Value = "Date"
ws1.Cells(4, 5).Value = "Account"
ws1.Cells(4, 6).Value = "Invoice Number"
ws1.Cells(4, 7).Value = "Amount"
ws1.Cells(4, 8).Value = "Total"

'Build out data array from original worksheet
lRow = os.Cells(Rows.Count, 1).End(xlUp).Row 'identifies last row to copy data from
'Copy Vendor Codes
Let CopyRange = "C2:C" & lRow + 1
Let PasteRange = "A5:A" & lRow + 5
os3.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy Invoice Date
Let CopyRange = "E1:E" & lRow
Let PasteRange = "D5:D" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).NumberFormat = "m/d/yyyy;@"
'Copy Invoices Notes
Let CopyRange = "H1:H" & lRow
Let PasteRange = "B5:B" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy Property Code
Let CopyRange = "I1:I" & lRow
Let PasteRange = "C5:C" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy Invoice Number
Let CopyRange = "G1:G" & lRow
Let PasteRange = "F5:F" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
'Copy GL Account
Let CopyRange = "K1:K" & lRow
Let PasteRange = "E5:E" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Replace what:="-", Replacement:="", LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
'Copy Amount
Let CopyRange = "J1:J" & lRow
Let PasteRange = "G5:G" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
'Copy Segment
Let CopyRange = "V1:V" & lRow
Let PasteRange = "I5:I" & lRow + 5
os.Range(CopyRange).Copy
ws1.Range(PasteRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

'Format the bottom part of funding request where the totals are
Let PasteRange = "C" & lRow + 6 & ":F" & lRow + 6
ws1.Range(PasteRange).Merge
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Value = "TOTAL VENDOR PAYMENTS"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(255, 255, 0)

Let PasteRange = "C" & lRow + 12 & ":F" & lRow + 12
ws1.Range(PasteRange).Merge
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Value = "TOTAL TO BE PAID OTHER"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(255, 255, 0)

Let PasteRange = "C" & lRow + 15 & ":F" & lRow + 15
ws1.Range(PasteRange).Merge
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Value = "TOTAL FUNDING REQUEST"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlDouble
    ws1.Range(PasteRange).Interior.Color = RGB(255, 255, 0)

Let PasteRange = "B" & lRow + 15 & ":B" & lRow + 15
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlDouble

Let PasteRange = "G" & lRow + 6 'Summing the Amounts
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Formula = "=SUM(G5:G" & lRow + 5 & ")"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(197, 217, 241)

Let PasteRange = "G" & lRow + 12 'Summing Sales Tax/Other
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Formula = "=SUM(G" & lRow + 8 & ":G" & lRow + 10 & ")"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws1.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"

Let PasteRange = "G" & lRow + 15 'Grand Sum
    ws1.Range(PasteRange).Font.Size = 14
    ws1.Range(PasteRange).Font.Name = "Calibri"
    ws1.Range(PasteRange).Font.FontStyle = "Bold"
    ws1.Range(PasteRange).Formula = "=SUM(G" & lRow + 6 & "+G" & lRow + 12 & ")"
    ws1.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws1.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlDouble
    ws1.Range(PasteRange).Interior.Color = RGB(197, 217, 241)

'This completes all the base formatting for the Funding Request
'''''''''''''''''''''
'Lets start to modify the data. We'll start with the second sheet.

'Again, starting with Formatting
'Format the cells to look like funding request
ws2.Columns("A").ColumnWidth = 38
ws2.Columns("B").ColumnWidth = 55
ws2.Columns("C:E").ColumnWidth = 13
ws2.Columns("F").ColumnWidth = 21
ws2.Columns("G").ColumnWidth = 16
ws2.Rows("1").RowHeight = 27
ws2.Range("A1:B1").Merge
    ws2.Range("A1").Font.Size = 12
    ws2.Range("A1").Font.Name = "Calibri"
    ws2.Range("A1").Font.FontStyle = "Bold"
ws2.Range("C1:G1").Merge
    ws2.Range("C1:G1").Font.Size = 20
    ws2.Range("C1:G1").Font.Name = "Calibri"
    ws2.Range("C1:G1").Font.FontStyle = "Bold"
    ws2.Range("C1:G1").Borders.LineStyle = xlContinuous
    ws2.Range("C1:G1").Borders.Weight = xlMedium
    ws2.Range("C1:G1").HorizontalAlignment = xlCenter
    ws2.Range("C1:G1").Interior.Color = RGB(255, 255, 153)
'Create the table title formatting
    ws2.Range("A3:G3").Font.Underline = xlUnderlineStyleSingle
    ws2.Range("A3:G3").Font.Size = 12
    ws2.Range("A3:G3").Font.Name = "Calibri"
    ws2.Range("A3:G3").Font.FontStyle = "Bold"
    ws2.Range("A3:G3").Borders(xlEdgeBottom).LineStyle = xlContinuous

'Create those headers with the formatting
ws2.Cells(1, 1).Value = "Church Street Funding Request " & Format(Now(), "mmmm dd, yyyy")
ws2.Cells(1, 3).Value = "By Property"
ws2.Cells(3, 1).Value = "Vendor"
ws2.Cells(3, 2).Value = "Invoice Notes"
ws2.Cells(3, 3).Value = "Property"
ws2.Cells(3, 4).Value = "Date"
ws2.Cells(3, 5).Value = "Account"
ws2.Cells(3, 6).Value = "Invoice Number"
ws2.Cells(3, 7).Value = "Amount"

'Copy Data
Let CopyRange = "A5:G" & lRow + 5
Let PasteRange = "A5:G" & lRow + 5
ws1.Range(CopyRange).Copy
ws2.Range(PasteRange).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    ws1.Range(PasteRange).HorizontalAlignment = xlLeft
    ws1.Range(PasteRange).Font.Size = 11
    ws1.Range(PasteRange).Font.Name = "Calibri"

'Sort Data
ws2.Range("C4").Value = "Site"
    ws2.Range("A4:G4").AutoFilter
    ws2.AutoFilter.Sort.SortFields. _
        Clear
    ws2.AutoFilter.Sort.SortFields. _
        Add Key:=Range("C4"), SortOn:=xlSortOnValues, Order:=xlAscending, _
        DataOption:=xlSortNormal
    With ws2.AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    ws2.Range("A4:G4").AutoFilter
ws2.Range("C4").Value = ""

'Find where -02 ends and label
searchValue = "2350-02"
    With ws2
        endRow = .Cells(Rows.Count, 3).End(xlUp).Row
        For i = 1 To endRow
            If .Cells(i + 4, 3) = searchValue Then
                lastSearch1 = i
            End If
        Next i
    End With

Let PasteRange = lastSearch1 + 5 & ":" & lastSearch1 + 7
ws2.Rows(PasteRange).EntireRow.Insert
Let PasteRange = "B" & lastSearch1 + 6 & ":G" & lastSearch1 + 6
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch1 + 6
        ws2.Range(PasteRange).Value = "Total 2350-02"
    Let PasteRange = "G" & lastSearch1 + 6
        ws2.Range(PasteRange).Formula = "=Sum(G5:G" & lastSearch1 + 5 & ")"

'Find where -03 ends and label
searchValue = "2350-03"
    With ws2
        endRow = .Cells(Rows.Count, 3).End(xlUp).Row
        For i = 1 To endRow
            If .Cells(i + lastSearch1 + 7, 3) = searchValue Then
                lastSearch2 = i + lastSearch1 + 7
            End If
        Next i
    End With

Let PasteRange = lastSearch2 + 1 & ":" & lastSearch2 + 3
ws2.Rows(PasteRange).EntireRow.Insert
Let PasteRange = "B" & lastSearch2 + 2 & ":G" & lastSearch2 + 2
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch2 + 2
        ws2.Range(PasteRange).Value = "Total 2350-03"
    Let PasteRange = "G" & lastSearch2 + 2
        ws2.Range(PasteRange).Formula = "=Sum(G" & lastSearch1 + 8 & ":G" & lastSearch2 + 1 & ")"

'Find where -04 ends and label
searchValue = "2350-04"
    With ws2
        endRow = .Cells(Rows.Count, 3).End(xlUp).Row
        For i = 1 To endRow
            If .Cells(i + lastSearch2 + 4, 3) = searchValue Then
                lastSearch3 = i + lastSearch2 + 4
            End If
        Next i
    End With

Let PasteRange = lastSearch3 + 1 & ":" & lastSearch3 + 3
ws2.Rows(PasteRange).EntireRow.Insert
Let PasteRange = "B" & lastSearch3 + 2 & ":G" & lastSearch3 + 2
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch3 + 2
        ws2.Range(PasteRange).Value = "Total 2350-04"
    Let PasteRange = "G" & lastSearch3 + 2
        ws2.Range(PasteRange).Formula = "=Sum(G" & lastSearch2 + 4 & ":G" & lastSearch3 + 1 & ")"

'Finish off The by Property Tab
Let PasteRange = "A" & lastSearch3 + 4 & ":G" & lastSearch3 + 4
    ws2.Range(PasteRange).Font.Size = 14
    ws2.Range(PasteRange).Font.Name = "Calibri"
    ws2.Range(PasteRange).Font.FontStyle = "Bold"
    ws2.Range(PasteRange).Borders(xlEdgeTop).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeBottom).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeRight).LineStyle = xlContinuous
    ws2.Range(PasteRange).Borders(xlEdgeLeft).LineStyle = xlContinuous
    ws2.Range(PasteRange).Interior.Color = RGB(197, 217, 241)
    Let PasteRange = "B" & lastSearch3 + 4
        ws2.Range(PasteRange).Value = "Total Funding Request"
    Let PasteRange = "G" & lastSearch3 + 4
        ws2.Range(PasteRange).Formula = "=Sum(G" & lastSearch1 + 6 & " + G" & lastSearch2 + 2 & " + G" & lastSearch3 + 2 & ")"

'The property tab should now be completely formatted (except Sales Tax, which is a manual entry
''''''''''''''''''
'Only thing remaining is to do the combined invoices thing.

Let i = 5
'While i < lRow + 5
    If ws1.Cells(i, 6) = ws1.Cells(i + 1, 6) Then 'And ws1.Cells(i, 6) = ws1.Cells(i + 2, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 3, 6) And _
    'ws1.Cells(i, 6) = ws1.Cells(i + 4, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 5, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 6, 6) And _
    'ws1.Cells(i, 6) = ws1.Cells(i + 7, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 8, 6) And ws1.Cells(i, 6) = ws1.Cells(i + 9, 6) Then
        Let CopyRange = ws1.Cells(i, 7) & ":" & ws1.Cells(i + 1, 7)
        Let PasteRange = ws1.Cells(i + 1, 8)
        ws1.Range(PasteRange).Value = CopyRange
    i = i + 1
'
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then
'    If ws1.Cells(i, 5) = ws1.Cells(i + 1, 5) Then

    End If
'Wend

ws2.Range("Z1").Copy
End Sub

Edit 2: The other post I linked is the process I want, but I would need a follow-up to delete all the non-final values, which include any non-duplicate invoices as well as the first iterations of the duplicates (meaning if it prints 11,518.70 in H5:H10, i'd need to clear H5:H9). I also don't know how I'd format the boxes using this way.

Edit 3:

Here is my partial solution. The only thing this doesn't accomplish (and I don't know how), is to create the boxes around the invoices which belong together.

'Only thing remaining is to do the combined invoices thing.

    With ws1.Range("H5:H" & lRow + 4)
        .ClearContents
        .Value = ws1.Evaluate("INDEX(SUMIF(F5:F" & lRow + 4 & ",F5:F" & lRow + 4 & ",G5:G" & lRow + 4 & "),)")
    End With

    i = 5
    For i = 5 To lRow + 4
        If ws1.Cells(i, 7).Value = ws1.Cells(i, 8).Value Then
            ws1.Cells(i, 8).Value = ""
        End If
    Next i

    i = 5
    For i = 5 To lRow + 4
        If ws1.Cells(i, 8).Value = ws1.Cells(i + 1, 8).Value Then
            ws1.Cells(i, 8).Value = ""
        End If
    Next i
    Let PasteRange = "H5:H" & lRow + 4
    ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"

Body:
Alright, for anyone who has a similar problem, here was my solution. I created an exhaustive solution set based on if there were duplicate values, and had different border stipulations for each. I'm sure it's not the fastest way, but now I have a deliverable.

'Only thing remaining is to do the combined invoices thing.

With ws1.Range("H5:H" & lRow + 4)
    .ClearContents
    .Value = ws1.Evaluate("INDEX(SUMIF(F5:F" & lRow + 4 & ",F5:F" & lRow + 4 & ",G5:G" & lRow + 4 & "),)")
End With

Let PasteRange = "G5:H" & lRow + 4
ws1.Range(PasteRange).Borders.LineStyle = xlContinuous

i = 5
For i = 5 To lRow + 4
    If ws1.Cells(i, 7).Value = ws1.Cells(i, 8).Value Then
        ws1.Cells(i, 8).Value = ""
        ws1.Cells(i, 8).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 8).Borders(xlEdgeRight).LineStyle = xlNone
        ws1.Cells(i, 8).Borders(xlEdgeLeft).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeRight).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeLeft).LineStyle = xlNone
    End If
Next i

i = 5
For i = 5 To lRow + 4
    If ws1.Cells(i, 8).Value = ws1.Cells(i + 1, 8).Value Then
        ws1.Cells(i, 8).Value = ""
        ws1.Cells(i, 8).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeBottom).LineStyle = xlNone
        ws1.Cells(i, 8).Borders(xlEdgeLeft).LineStyle = xlNone
        ws1.Cells(i, 7).Borders(xlEdgeRight).LineStyle = xlNone
        ws1.Cells(i + 1, 8).Borders(xlEdgeLeft).LineStyle = xlNone
        ws1.Cells(i + 1, 7).Borders(xlEdgeRight).LineStyle = xlNone
    End If
Next i

i = 5
For i = 5 To lRow + 4
    If ws1.Cells(i, 6).Value <> ws1.Cells(i - 1, 6).Value And ws1.Cells(i, 6).Value = ws1.Cells(i + 1, 6).Value Then
        ws1.Cells(i, 8).Borders(xlEdgeTop).LineStyle = xlContinuous
        ws1.Cells(i, 7).Borders(xlEdgeTop).LineStyle = xlContinuous
    End If
Next i

ws1.Range(PasteRange).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"


问:
FOSUserBundle edit EDITPAGE PROFILE
This is my code:

```<code><form action="{{ path('fos_user_profile_edit') }}" {{ form_enctype(form) }} method="POST" class="fos_user_profile_edit">
    <div class="edittext_registre1">{{ form_label(form.username) }}</div>
    <div class="editbox_registre1">{{ form_widget(form.username) }}</div>
    <br/><br/>
    <div class="edittext_registre2">{{ form_label(form.email) }}</div>
    <div class="editbox_registre2">{{ form_widget(form.email) }}</div>
    <br/><br/>
    <div class="edittext_registre3">{{ form_label(form.current_password) }}</div>
    <div class="editbox_registre3">{{ form_widget(form.current_password) }}</div>
    <br/><br/>
    <div>
        <input type="submit" value="{{ 'profile.edit.submit'| trans }}" />
    </div>
</form>
</code>```

When I click submit button, my profil have no change :(

but when I change my code by this code:

```<code><form action="{{ path('fos_user_profile_edit') }}" {{ form_enctype(form) }} method="POST" class="fos_user_profile_edit">

    {% include "FOSUserBundle:Profile:edit_content.html.twig" %}

    <div>
        <input type="submit" value="{{ 'profile.edit.submit'| trans }}" />
    </div>
</form>
</code>```

Why ?
What should I do?

Thank you so much.

答:
Have you referred to http://symfony.com/doc/current/form/form_customization.html? Havent worked with symfony for a while now, but as far as i remember, the following is the proper way to go. Can you please check if it works?

```<code>{{ form_start(form, { 'action': path('fos_user_profile_edit'), 'attr': { 'class': 'fos_user_profile_edit' } }) }}
  <div class="edittext_registre1">
    {{ form_label(form.username) }}
  </div>
  <div class="editbox_registre1">
    {{ form_errors(form.username) }}
    {{ form_widget(form.username) }}
  </div>
  <br/>
  <br/>
  <div class="edittext_registre2">
    {{ form_label(form.email) }}
  </div>
  <div class="editbox_registre2">
    {{ form_errors(form.email) }}
    {{ form_widget(form.email) }}
  </div>
  <br/>
  <br/>
  <div class="edittext_registre3">
    {{ form_label(form.current_password) }}
  </div>
  <div class="editbox_registre3">
    {{ form_errors(form.current_password) }}
    {{ form_widget(form.current_password) }}
  </div>
  <br/>
  <br/>
  {{ form_rest(form) }}
  <div>
    <input type="submit" value="{{ 'profile.edit.submit'|trans }}" />
  </div>
{{ form_end(form) }}
</code>```

Are there any errors rendered? (and does form_rest render any more fields? Maybe your original code had errors, because there were more required fields in fosuserbundle that were required but you were not including those fields in your form)

Title: FOSUserBundle edit EDITPAGE PROFILE

Body:
This is my code:

<form action="{{ path('fos_user_profile_edit') }}" {{ form_enctype(form) }} method="POST" class="fos_user_profile_edit">

{{ form_label(form.username) }}

{{ form_widget(form.username) }}

{{ form_label(form.email) }}

{{ form_widget(form.email) }}

{{ form_label(form.current_password) }}

{{ form_widget(form.current_password) }}

        <input type="submit" value="{{ 'profile.edit.submit'| trans }}" />

</form>

When I click submit button, my profil have no change :(

but when I change my code by this code:

<form action="{{ path('fos_user_profile_edit') }}" {{ form_enctype(form) }} method="POST" class="fos_user_profile_edit">

    {% include "FOSUserBundle:Profile:edit_content.html.twig" %}

        <input type="submit" value="{{ 'profile.edit.submit'| trans }}" />

</form>

Why ?
What should I do?

Thank you so much.

Body:
Have you referred to http://symfony.com/doc/current/form/form_customization.html? Havent worked with symfony for a while now, but as far as i remember, the following is the proper way to go. Can you please check if it works?

{{ form_start(form, { 'action': path('fos_user_profile_edit'), 'attr': { 'class': 'fos_user_profile_edit' } }) }}
  <div class="edittext_registre1">
    {{ form_label(form.username) }}
  </div>
  <div class="editbox_registre1">
    {{ form_errors(form.username) }}
    {{ form_widget(form.username) }}
  </div>
  <br/>
  <br/>
  <div class="edittext_registre2">
    {{ form_label(form.email) }}
  </div>
  <div class="editbox_registre2">
    {{ form_errors(form.email) }}
    {{ form_widget(form.email) }}
  </div>
  <br/>
  <br/>
  <div class="edittext_registre3">
    {{ form_label(form.current_password) }}
  </div>
  <div class="editbox_registre3">
    {{ form_errors(form.current_password) }}
    {{ form_widget(form.current_password) }}
  </div>
  <br/>
  <br/>
  {{ form_rest(form) }}
  <div>
    <input type="submit" value="{{ 'profile.edit.submit'|trans }}" />
  </div>
{{ form_end(form) }}

Are there any errors rendered? (and does form_rest render any more fields? Maybe your original code had errors, because there were more required fields in fosuserbundle that were required but you were not including those fields in your form)


问:
data binding - safeUnbox warning
after i upgrade AS gradle version to 2.3.0,
data binding encounter a warning :

Warning:selectMap[index] is a boxed field but needs to be un-boxed to execute selectMap[index] ? @android:color/white : @android:color/transparent. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap selectMap[index] with safeUnbox() to prevent the warning

selectMap is an ObservableMap, then i search this warning but got just few discussions and did not fix it

Android Studio 2.3.0-alpha1: Databinding + int unboxing causes compile errors

Databinding - data object is null on API 15-18

I follow the way in the links, modify selectMap[index] to safeUnbox(selectMap[index]) but got syntax error.

So anyone know how to fix this warning?

Edit :
Here is the xml file code

```<code><?xml version="1.0" encoding="utf-8"?>
</code>```

```<code><data class="SupportCountryViewHolderBinding">

    <variable
        name="viewModel"
        type="com.goodarc.care_about.activity.account.support_country.SupportCountryHolderViewModel" />

    <variable
        name="dataSource"
        type="com.goodarc.care_about.module.assets_file.SupportCountry" />

    <variable
        name="selectMap"
        type="android.databinding.ObservableMap<Integer, Boolean>" />

    <variable
        name="index"
        type="int" />
</data>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@{selectMap[index] ? @android:color/white : @android:color/transparent}"
    android:onClick="@{(v) -> viewModel.onItemSelectListener(selectMap, index)}"
    android:orientation="vertical"
    android:padding="20dp">

    <TextView
        style="@style/TitleLabel2"
        android:layout_gravity="center_vertical|start"
        android:text="@{dataSource.display}"
        android:textColor="@{selectMap[index] ? @android:color/black : @android:color/white}"
        tools:text="Taiwan (+886)" />
</LinearLayout>
</code>```

Build is succeed, but warning come out(i past above).

答:
I had the same warning, in my case changing the variable declaration from Boolean type to boolean type solve the problem:

From:

```<code><variable
        name="readOnly"
        type="Boolean" />
</code>```

To:

```<code><variable
        name="readOnly"
        type="boolean" />
</code>```

So, maybe you can try with:

```<code><variable
    name="selectMap"
    type="android.databinding.ObservableMap<Integer, boolean>" />
</code>```

Title: data binding - safeUnbox warning

Body:
after i upgrade AS gradle version to 2.3.0,
data binding encounter a warning :

Warning:selectMap[index] is a boxed field but needs to be un-boxed to execute selectMap[index] ? @android:color/white : @android:color/transparent. This may cause NPE so Data Binding will safely unbox it. You can change the expression and explicitly wrap selectMap[index] with safeUnbox() to prevent the warning

selectMap is an ObservableMap, then i search this warning but got just few discussions and did not fix it

Android Studio 2.3.0-alpha1: Databinding + int unboxing causes compile errors

Databinding - data object is null on API 15-18

I follow the way in the links, modify selectMap[index] to safeUnbox(selectMap[index]) but got syntax error.

So anyone know how to fix this warning?

Edit :
Here is the xml file code

<?xml version="1.0" encoding="utf-8"?>

<data class="SupportCountryViewHolderBinding">

    <variable
        name="viewModel"
        type="com.goodarc.care_about.activity.account.support_country.SupportCountryHolderViewModel" />

    <variable
        name="dataSource"
        type="com.goodarc.care_about.module.assets_file.SupportCountry" />

    <variable
        name="selectMap"
        type="android.databinding.ObservableMap<Integer, Boolean>" />

    <variable
        name="index"
        type="int" />
</data>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@{selectMap[index] ? @android:color/white : @android:color/transparent}"
    android:onClick="@{(v) -> viewModel.onItemSelectListener(selectMap, index)}"
    android:orientation="vertical"
    android:padding="20dp">

    <TextView
        style="@style/TitleLabel2"
        android:layout_gravity="center_vertical|start"
        android:text="@{dataSource.display}"
        android:textColor="@{selectMap[index] ? @android:color/black : @android:color/white}"
        tools:text="Taiwan (+886)" />
</LinearLayout>

Build is succeed, but warning come out(i past above).

Body:
I had the same warning, in my case changing the variable declaration from Boolean type to boolean type solve the problem:

From:

<variable
        name="readOnly"
        type="Boolean" />

To:

<variable
        name="readOnly"
        type="boolean" />

So, maybe you can try with:

<variable
    name="selectMap"
    type="android.databinding.ObservableMap&lt;Integer, boolean&gt;" />


问:
If NSNotificationCenter wouldn't exist, how would you implement it?
I was asked by this question and I actually don't know how to achieve it.

Please help.

答:
It's probably a singleton, meaning there is always one and only one in your app.

It's probably doing a "delegate" pattern, except with an array of delegates instead of only one delegate.

When you add an observer, the class that was added gets tossed into the array of delegates from #2.  (And when you remove an observer, it gets removed from that array.)

When you post a notification, the singleton in #1 loops through the delegate array (from #2) and calls the callback method associated with each delegate in it's array. (ok, technically it sends a message, but you get the idea)


问:
How calc() function works in CSS?
I am trying to use calc() for my css. I have created a simple Fiddle where I have two divs. One has a class with a style using calc(). But it's not having any effect. Div's height is not changing.

.cont {
  height: calc(100% - 20px);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="cont" style="background-color:blue">fsdfds</div>
<div style="background-color:red">1234</div></code>```

Fiddle

Thanks for help.

答:
The calc() function is working fine.

It's percentage heights you need to better understand.

In order for a percentage height to work on an element, there must be a defined height on the parent (unless the child is absolutely positioned).

Here's a post with a detailed explanation:

Working with the CSS height property and percentage values

Here's your fiddle demo with pixel heights instead: http://jsfiddle.net/UF3mb/697/

Title: How calc() function works in CSS?

Body:
I am trying to use calc() for my css. I have created a simple Fiddle where I have two divs. One has a class with a style using calc(). But it's not having any effect. Div's height is not changing.

.cont {
  height: calc(100% - 20px);
}

fsdfds

1234

Fiddle

Thanks for help.


问:
Cordys data aggregation
How to perform aggregation of data on cordys platform? I have not seen any variable of buffer that can hold the data while an iteration is in progress and finally when the iteration is over the collected data can be persisted to DB in a batch update.</p>

答:
Agreed, there are no defined aggregation methods available in cordys.
You can use while or for each loop which is available in cordys BPM or you can directly code in java and do further processing as per your business logic.

Title: Cordys data aggregation


问:
msbuild fails to compile vsto project
We recently installed a new development environment (Windows 10) from scratch with Visual Studio 2017 but we cannot manage to make msbuild  compile a Microsoft Office Addin for Word (vsto).
Within the Visual Studio installer we made sure to include the required components for Office Development.

It throws the following error (german translated to english)

error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found. Also, tried to find "OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" [...]

However, the project builds fine within Visual Studio.

On the old system, everything works fine, and i cannot remember having to configure anything at all.

答:
Okay, so I've worked through this one now. The problem was caused by me using Windows\Microsoft.NET\Framework64\v4...\Msbuild.exe.

It looks as though running msbuild from this location results in it not being able to implicitly locate many of the assemblies and build utilities required to build a VSTO project.

I resolved the problem by switching to using C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe

Title: msbuild fails to compile vsto project


问:
Visual studio build order working with nugets
Given a solution A that has 2 projects: 1,2 -

let's assume that project 2 depends on project 1.

Now , if we use a project references - than VS/MSBuild can resolve the correct build order and will always build project 1 before project 2.

But, what if we want to use Nugets to manage the dependencies?
Now project 2 defines that it depends on "nuget 1".
But it doesn't look like MSBuild is aware of this.
Is there any way to resolve this , without defining manually the build order in each solution?

答:
Is there any way to resolve this , without defining manually the build order in each solution?

Just as Lex Li mentioned, it`s the design of MSBuild and NuGet. When we use NuGets to manage the dependencies, MSBuild will build the dependence "nuget 1" first, it will work according to nuget design, find and download the dependence rather than build and generate the project 1.

In order to be able to get the dependence "nuget 1", we have to build the project 1 manually first, otherwise, MSBuild will throw an exception that could not find the dependence.

All of those are related to the design of NuGet, find and download the dependence rather than build and generate.

Hope this can help you.


问:
Angular 2 fill variable with return JSON info from HTTP Request
I'm pretty new on Angular2, and I'm trying to obtain the key/value pair from a JSON file returned by a Http request. I want to store them on the objectResource property so I can retrieve them on the template.

This is my component.ts:

```<code>export class ResourceDetailComponent implements OnInit {

    objectResource: any = Array();
    id:any;
    sub:any;

    constructor(private contentService: ContentService, private route: ActivatedRoute) {

        this.sub = this.route.params.subscribe(params => {
            this.id = +params['id'];
        });

        this.getResource(this.id);
     }

    ngOnInit(){}

    private getResource(id:number) {
        return this.contentService.getSpecificResource(id).then(res => this.objectResource.push(res));
    }

}
</code>```

and this is mi service.ts:

```<code>public getSpecificResource(id:number) {
        return this.http.get(`http://resources.dev/v1/resources/show/${id}`)
        .toPromise()
        .then(res => res.json());
    }
</code>```

when I do console.log on res I obtain this log, which mean the service is doing the request as expected:

```<code>Object {
    id: 1,
    name: "quisquam",
    image: "http://lorempixel.com/480/480/?88330",
    description: "Consequuntur quo provident alias aut rerum.",
    author: "Marc Mann Sr."
}
</code>```

I've tried to retrieve these values on the template using {{objectResource.name}} but isn't working, and I don't know how can I access this values from the template.

答: Angular's change detection is not triggered when an object is mutated (e.g. an element is added to your array).  See Triggering Angular2 change detection manually.  Specifically this solution https://stackoverflow.com/a/42695581/3103979</p>

Body:
I'm pretty new on Angular2, and I'm trying to obtain the key/value pair from a JSON file returned by a Http request. I want to store them on the objectResource property so I can retrieve them on the template.

This is my component.ts:

export class ResourceDetailComponent implements OnInit {

    objectResource: any = Array();
    id:any;
    sub:any;

    constructor(private contentService: ContentService, private route: ActivatedRoute) {

        this.sub = this.route.params.subscribe(params => {
            this.id = +params['id'];
        });

        this.getResource(this.id);
     }

    ngOnInit(){}

    private getResource(id:number) {
        return this.contentService.getSpecificResource(id).then(res => this.objectResource.push(res));
    }

}

and this is mi service.ts:

public getSpecificResource(id:number) {
        return this.http.get(`http://resources.dev/v1/resources/show/${id}`)
        .toPromise()
        .then(res => res.json());
    }

when I do console.log on res I obtain this log, which mean the service is doing the request as expected:

Object {
    id: 1,
    name: "quisquam",
    image: "http://lorempixel.com/480/480/?88330",
    description: "Consequuntur quo provident alias aut rerum.",
    author: "Marc Mann Sr."
}

I've tried to retrieve these values on the template using {{objectResource.name}} but isn't working, and I don't know how can I access this values from the template.