title: Read and write an excel file from Azure Blob Storage without downloading it to local file in Java
body: <p>I am using <strong>azure-storage</strong> dependency to <strong>create a reference of azure directory</strong> then after downloading the file in local system I am able to read and write using <strong>poi-ooxml library</strong> then again uploading the same file in azure storage.</p>
  <p><strong>I just want to remove this local downloading thing. Is there any way to read and write the excel file without downloading it in local.</strong></p>
  <p>Dependencies Used.</p>
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;com.microsoft.azure&lt;/groupId&gt;
          &lt;artifactId&gt;azure-storage&lt;/artifactId&gt;
          &lt;version&gt;8.4.0&lt;/version&gt;
      &lt;/dependency&gt;
      
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
          &lt;artifactId&gt;poi&lt;/artifactId&gt;
          &lt;version&gt;3.15&lt;/version&gt;
      &lt;/dependency&gt;
      
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
          &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
          &lt;version&gt;3.15&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  <p>Code</p>
  <pre><code>try {
          CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
          CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
          CloudBlobContainer container = blobClient.getContainerReference(containerName);
          CloudBlobDirectory downloadDirectory = container.getDirectoryReference(dowloadDirectoryName);
  
          for(ListBlobItem blobItem: downloadDirectory.listBlobs()) {
  
              if(blobItem instanceof CloudBlockBlob) {
  
                  CloudBlockBlob cloudBlob = (CloudBlockBlob) blobItem;
                  File inputFile = new File(cloudBlob.getName());
                  cloudBlob.downloadToFile(inputFile.getAbsolutePath());
                  
                  FileInputStream inputStream = new FileInputStream(inputFile);
                  Workbook workbook = new HSSFWorkbook(inputStream); 
                  /*Workbook workbook = WorkbookFactory.create(inputFile);*/
                  Sheet sheet = workbook.getSheetAt(0);       
                  log.info(&quot;Cell No 0 : &quot;+sheet.getRow(0).getCell(0).getStringCellValue());
                  for (int i = 1; i &lt;= sheet.getLastRowNum(); i++) {
                      Cell reasonLabel = sheet.getRow(i).createCell(2);
                      reasonLabel.setCellValue(&quot;Added one cell&quot;);
                  }
                  
                  File outputFile = new File(cloudBlob.getName().split(&quot;\\.&quot;)[0]+&quot;01.xls&quot;);
                  FileOutputStream outputStream = new FileOutputStream(outputFile);
                  workbook.write(outputStream);
                  outputStream.close();
                  workbook.close();
                  
                  CloudBlobDirectory uploadDirectory =  container.getDirectoryReference(uploadDirectoryName);
                  CloudBlockBlob uploadBlob = uploadDirectory.getBlockBlobReference(outputFile.getName());
                  FileInputStream fileInputStream = new FileInputStream(outputFile);
                  uploadBlob.upload(fileInputStream, outputFile.getTotalSpace());
                  fileInputStream.close();
                  outputFile.delete();
                  
              }
          }
      } catch(Exception ex) {
          log.error(ex.getMessage());
          throw ex;
      }
  </code></pre>