working on it ...

Filters

Explore Public Snippets

Sort by

Found 22k snippets matching: poi

    public by sukhjinderkahlon  326315  7  5  0

    How to Work with Excel Files Using Apache POI

    This code will work as a utility to read and write excel files using Apache POI Library. 3.13
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.xssf.usermodel.XSSFCell;
    import org.apache.poi.xssf.usermodel.XSSFRow;
    import org.apache.poi.xssf.usermodel.XSSFSheet;
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    
    public class ExcelUtils {
    
    	private static HSSFSheet ExcelWSheet;
    	private static HSSFWorkbook ExcelWBook;
    	private static HSSFCell Cell;
    
    	private static HSSFRow Row;
    	
    	private static String filePath;
    	public static void setExcelFile(String Path,String SheetName) throws Exception {
    
    			try {
    
       			// Open the Excel file
    				filePath=Path;
    
    			FileInputStream ExcelFile = new FileInputStream(Path);
    
    			// Access the required test data sheet
    
    			ExcelWBook = new HSSFWorkbook(ExcelFile);
    
    			ExcelWSheet = ExcelWBook.getSheet(SheetName);
    			
    
    			} catch (Exception e){
    
    				throw (e);
    
    			}
    
    	}
    
    	//This method is to read the test data from the Excel cell, in this we are passing parameters as Row num and Col num
    
        public static String getCellData(int RowNum, int ColNum) throws Exception{
    
    			try{
    
      			Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
    
      			String CellData = Cell.getStringCellValue();
    
      			return CellData;
    
      			}catch (Exception e){
    
    				return"";
    
      			}
    
        }
    
    
        
      //This method is to write in the Excel cell, Row num and Col num are the parameters
    
    	public static void setCellData(String Result,  int RowNum, int ColNum) throws Exception	{
    
    			try{
    
      			Row  = ExcelWSheet.getRow(RowNum);
    
    			Cell = Row.getCell(ColNum, Row.RETURN_BLANK_AS_NULL);
    
    			if (Cell == null) {
    
    				Cell = Row.createCell(ColNum);
    
    				Cell.setCellValue(Result);
    
    				} else {
    
    					Cell.setCellValue(Result);
    
    				}
    
      // Constant variables Test Data path and Test Data file name
    
      				FileOutputStream fileOut = new FileOutputStream(filePath);
    
      				ExcelWBook.write(fileOut);
    
      				fileOut.flush();
    
    					fileOut.close();
    
    				}catch(Exception e){
    
    					throw (e);
    
    			}
    
    		}
    
    	
    }
              

    public by zonaro  323292  2  7  0

    Crop Image on C#

    Simple snippet to Crop Image from up-left point
    public static Bitmap CropImage(this Bitmap source, Rectangle section)
           {
               Bitmap bmp = new Bitmap(section.Width, section.Height);
               Graphics g = Graphics.FromImage(bmp); 
               g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel); 
               return bmp;
           }
    

    public by skaggej  230788  1  6  0

    SharePoint 2010 - View Resource Measures for Sandboxed Solutions

    Ever wonder exactly what "300 points" means for you sandboxed solutions' resource quota in SharePoint 2010? Run the following PowerShell script in the SharePoint 2010 Management Shell and you'll be able to see it for yourself.
    $resourceMeasures = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local.ResourceMeasures
    $resourceMeasures | Select Name, ResourcesPerPoint
    

    public by sherazam  184671  0  5  0

    How to Render an Image of 3D Model from the Camera inside .NET Application

    This Technical tip explains how .NET developers can render an image of 3D model from the camera inside their .NET applications. Using Aspose.3D for .NET, developers can render an image to view a realistic image of 3D model, with or without the enhanced background, textures, shadows and also adjust the image size. The Render method exposed by the Sc
    // Enter here the actual content of the snippet.            // this code example creates a camera in a 3D scene, sets its target and render an image.
    
    // [C# Code Sample]
    
    // For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
    // The path to the documents directory.
    string MyDir = RunExamples.GetDataDir();
    
    // Load scene from file
    Scene scene = new Scene(MyDir + "camera.3ds");
    // Create a camera at (10,10,10) and look at the origin point for rendering,
    // it must be attached to the scene before render
    Camera camera = new Camera();
    scene.RootNode.CreateChildNode("camera", camera);
    camera.ParentNode.Transform.Translation = new Vector3(10, 10, 10);
    camera.LookAt = Vector3.Origin;
    
    // Specify the image render option
    ImageRenderOptions opt = new ImageRenderOptions();
    // Set the background color
    opt.BackgroundColor = Color.AliceBlue;
    // Tells renderer where the it can find textures
    opt.AssetDirectories.Add(MyDir + "textures");
    // Turn on shadow
    opt.EnableShadows = true;
    // Render the scene in given camera's perspective into specified png file with size 1024x1024
    scene.Render(camera, MyDir + "Render3DModelImageFromCamera_out_.png", new Size(1024, 1024), ImageFormat.Png, opt);
    
    //[VB.NET Code Sample]
    
    ' For complete examples and data files, please go to https://github.com/aspose-3d/Aspose.3D-for-.NET
    ' The path to the documents directory.
    Dim MyDir As String = RunExamples.GetDataDir()
    
    ' Load scene from file
    Dim scene As New Scene(MyDir & Convert.ToString("camera.3ds"))
    ' Create a camera at (10,10,10) and look at the origin point for rendering,
    ' it must be attached to the scene before render
    Dim camera As New Camera()
    scene.RootNode.CreateChildNode("camera", camera)
    camera.ParentNode.Transform.Translation = New Vector3(10, 10, 10)
    camera.LookAt = Vector3.Origin
    
    ' Specify the image render option
    Dim opt As New ImageRenderOptions()
    ' Set the background color
    opt.BackgroundColor = Color.AliceBlue
    ' Tells renderer where the it can find textures
    opt.AssetDirectories.Add(MyDir & Convert.ToString("textures"))
    ' Turn on shadow
    opt.EnableShadows = True
    ' Render the scene in given camera's perspective into specified png file with size 1024x1024
    scene.Render(camera, MyDir & Convert.ToString("Render3DModelImageFromCamera_out_.png"), New Size(1024, 1024), ImageFormat.Png, opt)
    

    public by Geometry  76110  0  5  0

    Convert: Converts a array of signed 32-bit integer samples into a array of 32-bit floating point samples.

    Converts a array of signed 32-bit integer samples into a array of 32-bit floating point samples. The original sample. The resulting sample.
    /// <summary>
    ///   Converts a array of signed 32-bit integer samples
    ///   into a array of 32-bit floating point samples.
    /// </summary>
    /// 
    /// <param name="from">The original sample.</param>
    /// <param name="to">The resulting sample.</param>
    /// 
    public static void Convert(Int32[] from, Int32[] to)
    {
        for (int i = 0; i < from.Length; i++)
            to[i] = (int)((double)from[i] * 0x7FFFFFFF);
    }

    public by Geometry  62425  0  5  0

    Round: Rounds a double-precision floating-point number array to a specified number of fractional digits.

    Rounds a double-precision floating-point number array to a specified number of fractional digits.
    /// <summary>
    ///   Rounds a double-precision floating-point number array to a specified number of fractional digits.
    /// </summary>
    public static double[] Round(double[] vector, int decimals = 0)
    {
        if (vector == null) throw new ArgumentNullException("vector");
    
        double[] result = new double[vector.Length];
        for (int i = 0; i < result.Length; i++)
            result[i] = Math.Round(vector[i], decimals);
        return result;
    }

    public by Geometry  49805  0  5  0

    FromData: Creates a new k-dimensional tree from the given points.

    Creates a new k-dimensional tree from the given points. The type of the value to be stored. The points to be added to the tree. Whether the given vector can be ordered in place. Passing true will change the original order of the vector. If set to false, all operations will be performed on an extra copy of the vector. A pop
    /// <summary>
    ///   Creates a new k-dimensional tree from the given points.
    /// </summary>
    /// 
    /// <typeparam name="T">The type of the value to be stored.</typeparam>
    /// 
    /// <param name="points">The points to be added to the tree.</param>
    /// <param name="inPlace">Whether the given <paramref name="points"/> vector
    ///   can be ordered in place. Passing true will change the original order of
    ///   the vector. If set to false, all operations will be performed on an extra
    ///   copy of the vector.</param>
    /// 
    /// <returns>A <see cref="KDTree{T}"/> populated with the given data points.</returns>
    /// 
    public static KDTree<T> FromData<T>(double[][] points, bool inPlace = false)
    {
        if (points == null)
            throw new ArgumentNullException("points");
    
        if (points.Length == 0)
            throw new ArgumentException("Insufficient points for creating a tree.");
    
        int leaves;
    
        var root = KDTree<T>.CreateRoot(points, inPlace, out leaves);
    
        return new KDTree<T>(points[0].Length, root, points.Length, leaves);
    }

    public by Geometry  45179  0  4  0

    Main: The main entry point for the application.

    The main entry point for the application.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());
    }

    public by Geometry  42700  0  3  0

    ToDecimal: Converts a multidimensional integer array to a jagged decimal fixed-point array.

    Converts a multidimensional integer array to a jagged decimal fixed-point array.
    /// <summary>
            ///   Converts a multidimensional integer array to a jagged decimal fixed-point array.
            /// </summary>
            /// 
    #if NET45
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
    #endif
            public static decimal[][] ToDecimal(this int[,] value, decimal[][] result)
            {
                            for (int i = 0; i < result.Length; i++)
                    for (int j = 0; j < result[i].Length; j++)
                        result[i][j] = (Decimal)value[i, j];
                return result;
            }

    public by Geometry  36979  0  3  0

    ToSingle: Converts a multidimensional double-precision floating point array to a multidimensional single-precision floating point array.

    Converts a multidimensional double-precision floating point array to a multidimensional single-precision floating point array.
    /// <summary>
            ///   Converts a multidimensional double-precision floating point array to a multidimensional single-precision floating point array.
            /// </summary>
            /// 
    #if NET45
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
    #endif
            public static float[,] ToSingle(this double[,] value, float[,] result)
            {
                unsafe
                {
                    fixed (double* src = value)
                    fixed (float* dst = result)
                    {
                        for (int i = 0; i < value.Length; i++)
                            dst[i] = (Single)src[i];
                    }
                }
    
                return result;
            }
    • Public Snippets
    • Channels Snippets