Question: I am using global variable in my `.cshtml` view as below-

```
@{
string canvasimage="";
}

```

Where I want to put some value in this using jquery-

```
<script>
    function GetData() {
        var image = $('#canvasoverdues canvas');
        var src = image[0].toDataURL("image/png");
        src = src.replace('data:image/png;base64,', '');
        @canvasimage=src;
    };
</script>

```

and then want to use this global variable in anchor tag as below-

```
<a href="/PDF/Certificate/?filename="+@canvasimage+" id="canvasbutton" >convert to image</a>

```

But I get syntax error in using this global variable in script. 

My question is how can we use this global variable and assign it a value.

If this is not possible kindly let me know how do I send value of function `GetData()` into parameter named `filename` in anchor?

Answer: 
You should read the file using something like that:

Read the file to a String usign Files.readAllbytes() and then split the content into a list of Strings: 

Then you should apply some java project like apache POI here is a example using excel:

<http://poi.apache.org/spreadsheet/how-to.html#sxssf>

Good luck!!
Use JExcelpApi, <http://jexcelapi.sourceforge.net/>

Download Link: <http://sourceforge.net/projects/jexcelapi/files/jexcelapi/2.6.12/>

Tutorial: <http://www.andykhan.com/jexcelapi/tutorial.html>