Wednesday 30 August 2017

Excel Formula | Search text between two specific cells or text

=IFERROR(MID($B2,FIND(J$1,$B2)+LEN(J$1)+1,FIND(":",MID($B2,FIND(J$1,$B2)+LEN(J$1)+1,LEN($B2)-FIND(J$1,$B2)+LEN(J$1)))),MID($B2,FIND(J$1,$B2)+LEN(J$1)+1,LEN($B2)-FIND(J$1,$B2)+1))


=IFERROR(MID(B2,FIND($K$1,B2)+12,LEN(B2)-FIND($K$1,B2)),"")

Tuesday 22 August 2017

Convert URL to Image in Excel and save to Folder | URL to Image

Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Dim Ret As Long

'~~> This is where the images will be saved. Change as applicable
Const FolderName As String = "C:\Temp\"

Sub Sample()
    Dim ws As Worksheet
    Dim LastRow As Long, i As Long
    Dim strPath As String

    '~~> Name of the sheet which has the list
    Set ws = Sheets("Sheet1")

    LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row

    For i = 2 To LastRow '<~~ 2 because row 1 has headers
        strPath = FolderName & ws.Range("A" & i).Value & ".jpg"

        Ret = URLDownloadToFile(0, ws.Range("B" & i).Value, strPath, 0, 0)

        If Ret = 0 Then
            ws.Range("C" & i).Value = "File successfully downloaded"
        Else
            ws.Range("C" & i).Value = "Unable to download the file"
        End If
    Next i
End Sub

Saturday 19 August 2017

load and read file line by line in java ?

load and read  file line by line in java :

package test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class ReadStringFromFileLineByLine {

public static void main(String[] args) {
try {
File file = new File("file location"); // location of file
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
StringBuffer stringBuffer = new StringBuffer();
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuffer.append(line);
stringBuffer.append("\n");
}
fileReader.close();
System.out.println("Contents of file:");
System.out.println(stringBuffer.toString());

} catch (IOException e) {
e.printStackTrace();
}
}
}